mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-26 15:03:17 +00:00
Update v1.1 api
This commit is contained in:
parent
491843ac6c
commit
78d82c7c2c
1 changed files with 31 additions and 1 deletions
|
@ -18,6 +18,8 @@ use App\Services\AccountService;
|
|||
use App\Services\StatusService;
|
||||
use App\Services\ProfileStatusService;
|
||||
use Jenssegers\Agent\Agent;
|
||||
use Mail;
|
||||
use App\Mail\PasswordChange;
|
||||
|
||||
class ApiV1Dot1Controller extends Controller
|
||||
{
|
||||
|
@ -231,6 +233,19 @@ class ApiV1Dot1Controller extends Controller
|
|||
$user->password = bcrypt($request->input('new_password'));
|
||||
$user->save();
|
||||
|
||||
$log = new AccountLog;
|
||||
$log->user_id = $user->id;
|
||||
$log->item_id = $user->id;
|
||||
$log->item_type = 'App\User';
|
||||
$log->action = 'account.edit.password';
|
||||
$log->message = 'Password changed';
|
||||
$log->link = null;
|
||||
$log->ip_address = $request->ip();
|
||||
$log->user_agent = $request->userAgent();
|
||||
$log->save();
|
||||
|
||||
Mail::to($request->user())->send(new PasswordChange($user));
|
||||
|
||||
return $this->json(AccountService::get($user->profile_id));
|
||||
}
|
||||
|
||||
|
@ -324,9 +339,24 @@ class ApiV1Dot1Controller extends Controller
|
|||
})
|
||||
->toArray();
|
||||
|
||||
$passwordChanges = AccountLog::whereUserId($user->id)
|
||||
->whereAction('account.edit.password')
|
||||
->where('created_at', '>', now()->subDays(14))
|
||||
->orderByDesc('created_at')
|
||||
->limit(10)
|
||||
->get()
|
||||
->map(function($mail) {
|
||||
return [
|
||||
'type' => 'Password Change',
|
||||
'created_at' => $mail->created_at
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
$res = [
|
||||
'email_verifications' => $emailVerifications,
|
||||
'password_resets' => $passwordResets
|
||||
'password_resets' => $passwordResets,
|
||||
'password_changes' => $passwordChanges
|
||||
];
|
||||
|
||||
return $this->json($res);
|
||||
|
|
Loading…
Reference in a new issue