Skip to content

Commit 1ea2e41

Browse files
committed
User Model namespace changed
1 parent 19180c3 commit 1ea2e41

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/Http/Controllers/Security/Controller.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Diviky\Security\Http\Controllers\Security;
66

77
use App\Http\Controllers\Controller as BaseController;
8-
use App\User;
8+
use App\Models\User;
99
use Diviky\Bright\Mail\Mailable;
1010
use Diviky\Security\Models\LoginHistory;
1111
use Diviky\Security\Models\Session;
@@ -25,13 +25,13 @@ public function index(): array
2525

2626
public function twofa($user_id = null): array
2727
{
28-
$g2fa = app('pragmarx.google2fa');
28+
$g2fa = app('pragmarx.google2fa');
2929
$user_id = $user_id ?: user('id');
3030

3131
$user = User::find($user_id);
3232

3333
if ($this->isMethod('post')) {
34-
$task = $this->post('task');
34+
$task = $this->post('task');
3535
$user_id = $user->id;
3636

3737
if ('verify' == $task) {
@@ -40,26 +40,26 @@ public function twofa($user_id = null): array
4040
]);
4141

4242
$secret = $this->post('secret');
43-
$code = $this->post('code');
44-
$valid = $g2fa->verifyKey($secret, $code);
43+
$code = $this->post('code');
44+
$valid = $g2fa->verifyKey($secret, $code);
4545

4646
if (!$valid) {
4747
return [
48-
'status' => 'ERROR',
48+
'status' => 'ERROR',
4949
'message' => 'Two factor Authentication FAILED.',
5050
];
5151
}
5252

5353
return [
54-
'status' => 'OK',
54+
'status' => 'OK',
5555
'message' => 'Two factor Authentication SUCCESS.',
5656
];
5757
}
5858

5959
$password = $user->password;
6060
if (!Hash::check($this->input('password'), $password)) {
6161
return [
62-
'status' => 'ERROR',
62+
'status' => 'ERROR',
6363
'message' => __('Your current password didn\'t match.'),
6464
];
6565
}
@@ -69,24 +69,24 @@ public function twofa($user_id = null): array
6969
$user->save();
7070

7171
return [
72-
'status' => 'OK',
72+
'status' => 'OK',
7373
'message' => 'Two factor Authentication DISABLED for your account.',
74-
'reload' => true,
74+
'reload' => true,
7575
];
7676
}
7777

7878
$this->rules([
7979
'secret' => 'required',
80-
'code' => 'required',
80+
'code' => 'required',
8181
]);
8282

8383
$secret = $this->post('secret');
84-
$code = $this->post('code');
85-
$valid = $g2fa->verifyKey($secret, $code);
84+
$code = $this->post('code');
85+
$valid = $g2fa->verifyKey($secret, $code);
8686

8787
if (!$valid) {
8888
return [
89-
'status' => 'ERROR',
89+
'status' => 'ERROR',
9090
'message' => 'Two factor Authentication FAILED. Try with new code.',
9191
];
9292
}
@@ -101,9 +101,9 @@ public function twofa($user_id = null): array
101101
);
102102

103103
$tags = [
104-
'row' => $user,
104+
'row' => $user,
105105
'secret' => $secret,
106-
'url' => $qrcode,
106+
'url' => $qrcode,
107107
];
108108

109109
(new Mailable())
@@ -114,16 +114,16 @@ public function twofa($user_id = null): array
114114
->deliver($user);
115115

116116
return [
117-
'status' => 'OK',
117+
'status' => 'OK',
118118
'message' => 'Two factor Authentication ENABLED for your account.',
119-
'reload' => true,
119+
'reload' => true,
120120
];
121121
}
122122

123123
$enabled = false;
124124

125125
if ($user->google2fa_secret) {
126-
$secret = $user->google2fa_secret;
126+
$secret = $user->google2fa_secret;
127127
$enabled = true;
128128
} else {
129129
$secret = $g2fa->generateSecretKey();
@@ -136,9 +136,9 @@ public function twofa($user_id = null): array
136136
);
137137

138138
return [
139-
'user' => $user,
140-
'qrcode' => $qrcode,
141-
'secret' => $secret,
139+
'user' => $user,
140+
'qrcode' => $qrcode,
141+
'secret' => $secret,
142142
'enabled' => $enabled,
143143
];
144144
}
@@ -153,7 +153,7 @@ public function logins(): array
153153
$data = $this->all();
154154

155155
$rows = LoginHistory::filter($data)
156-
->where('user_id', user()->id)
156+
->where('user_id', user('id'))
157157
->ordering($data, ['created_at' => 'desc'])
158158
->paginate();
159159

@@ -169,7 +169,7 @@ public function sessions(): array
169169
$date = carbon();
170170
$date->subMinutes(config('session.lifetime'));
171171
$timestamp = $date->getTimestamp();
172-
$data = $this->all();
172+
$data = $this->all();
173173

174174
$rows = Session::filter($data)
175175
->where('user_id', user()->id)

0 commit comments

Comments
 (0)