@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | Password Reminder Language Lines |
8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | - 'password' => 'يجب أن لا يقل طول كلمة السر عن ستة أحرف، كما يجب أن تتطابق مع حقل التأكيد', |
|
17 | - 'reset' => 'تمت إعادة تعيين كلمة السر', |
|
18 | - 'sent' => 'تم إرسال تفاصيل استعادة كلمة السر الخاصة بك إلى بريدك الإلكتروني', |
|
19 | - 'token' => '.رمز استعادة كلمة السر الذي أدخلته غير صحيح', |
|
20 | - 'user' => 'لم يتم العثور على أيّ حسابٍ بهذا العنوان الإلكتروني', |
|
16 | + 'password' => 'يجب أن لا يقل طول كلمة السر عن ستة أحرف، كما يجب أن تتطابق مع حقل التأكيد', |
|
17 | + 'reset' => 'تمت إعادة تعيين كلمة السر', |
|
18 | + 'sent' => 'تم إرسال تفاصيل استعادة كلمة السر الخاصة بك إلى بريدك الإلكتروني', |
|
19 | + 'token' => '.رمز استعادة كلمة السر الذي أدخلته غير صحيح', |
|
20 | + 'user' => 'لم يتم العثور على أيّ حسابٍ بهذا العنوان الإلكتروني', |
|
21 | 21 | |
22 | 22 | ]; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | Disable Confirm Email |
8 | 8 | |-------------------------------------------------------------------------- |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | | |
12 | 12 | */ |
13 | 13 | |
14 | - 'disable_confirm_email' => env('DISABLE_CONFIRM_EMAIL', false), |
|
14 | + 'disable_confirm_email' => env('DISABLE_CONFIRM_EMAIL', false), |
|
15 | 15 | |
16 | - /* |
|
16 | + /* |
|
17 | 17 | |-------------------------------------------------------------------------- |
18 | 18 | | Confirm Email URL |
19 | 19 | |-------------------------------------------------------------------------- |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | | |
23 | 23 | */ |
24 | 24 | |
25 | - 'confrim_email_url' => env('CONFIRM_EMAIL_URL'), |
|
25 | + 'confrim_email_url' => env('CONFIRM_EMAIL_URL'), |
|
26 | 26 | |
27 | - /* |
|
27 | + /* |
|
28 | 28 | |-------------------------------------------------------------------------- |
29 | 29 | | Reset Password URL |
30 | 30 | |-------------------------------------------------------------------------- |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | | |
34 | 34 | */ |
35 | 35 | |
36 | - 'reset_password_url' => env('RESET_PASSWORD_URL'), |
|
36 | + 'reset_password_url' => env('RESET_PASSWORD_URL'), |
|
37 | 37 | |
38 | - /* |
|
38 | + /* |
|
39 | 39 | |-------------------------------------------------------------------------- |
40 | 40 | | Passport Client Id |
41 | 41 | |-------------------------------------------------------------------------- |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | | |
45 | 45 | */ |
46 | 46 | |
47 | - 'passport_client_id' => env('PASSWORD_CLIENT_ID'), |
|
47 | + 'passport_client_id' => env('PASSWORD_CLIENT_ID'), |
|
48 | 48 | |
49 | - /* |
|
49 | + /* |
|
50 | 50 | |-------------------------------------------------------------------------- |
51 | 51 | | Passport Client Secret |
52 | 52 | |-------------------------------------------------------------------------- |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | | |
56 | 56 | */ |
57 | 57 | |
58 | - 'passport_client_secret' => env('PASSWORD_CLIENT_SECRET'), |
|
58 | + 'passport_client_secret' => env('PASSWORD_CLIENT_SECRET'), |
|
59 | 59 | |
60 | - /* |
|
60 | + /* |
|
61 | 61 | |-------------------------------------------------------------------------- |
62 | 62 | | Relations Between Models |
63 | 63 | |-------------------------------------------------------------------------- |
@@ -66,88 +66,88 @@ discard block |
||
66 | 66 | | |
67 | 67 | */ |
68 | 68 | |
69 | - 'relations' => [ |
|
70 | - 'users' => [ |
|
71 | - 'list' => [], |
|
72 | - 'find' => [], |
|
73 | - 'findby' => [], |
|
74 | - 'paginate' => [], |
|
75 | - 'paginateby' => [], |
|
76 | - 'first' => [], |
|
77 | - 'search' => [], |
|
78 | - 'account' => [], |
|
79 | - 'group' => [], |
|
80 | - 'deleted' => [], |
|
81 | - ], |
|
82 | - 'permissions' => [ |
|
83 | - 'list' => [], |
|
84 | - 'find' => [], |
|
85 | - 'findby' => [], |
|
86 | - 'paginate' => [], |
|
87 | - 'paginateby' => [], |
|
88 | - 'first' => [], |
|
89 | - 'search' => [], |
|
90 | - 'deleted' => [], |
|
91 | - ], |
|
92 | - 'groups' => [ |
|
93 | - 'list' => [], |
|
94 | - 'find' => [], |
|
95 | - 'findby' => [], |
|
96 | - 'paginate' => [], |
|
97 | - 'paginateby' => [], |
|
98 | - 'first' => [], |
|
99 | - 'search' => [], |
|
100 | - 'deleted' => [], |
|
101 | - ], |
|
102 | - 'oauthClients' => [ |
|
103 | - 'list' => [], |
|
104 | - 'find' => [], |
|
105 | - 'findby' => [], |
|
106 | - 'paginate' => [], |
|
107 | - 'paginateby' => [], |
|
108 | - 'first' => [], |
|
109 | - 'search' => [], |
|
110 | - 'account' => [], |
|
111 | - 'group' => [], |
|
112 | - 'deleted' => [], |
|
113 | - ], |
|
114 | - 'notifications' => [ |
|
115 | - 'list' => [], |
|
116 | - 'unread' => [], |
|
117 | - ], |
|
118 | - 'pushNotificationDevices' => [ |
|
119 | - 'list' => [], |
|
120 | - 'find' => [], |
|
121 | - 'findby' => [], |
|
122 | - 'paginate' => [], |
|
123 | - 'paginateby' => [], |
|
124 | - 'first' => [], |
|
125 | - 'search' => [], |
|
126 | - 'deleted' => [], |
|
127 | - ], |
|
128 | - 'reports' => [ |
|
129 | - 'list' => [], |
|
130 | - 'find' => [], |
|
131 | - 'findby' => [], |
|
132 | - 'paginate' => [], |
|
133 | - 'paginateby' => [], |
|
134 | - 'first' => [], |
|
135 | - 'search' => [], |
|
136 | - 'deleted' => [], |
|
137 | - ], |
|
138 | - 'settings' => [ |
|
139 | - 'list' => [], |
|
140 | - 'find' => [], |
|
141 | - 'findby' => [], |
|
142 | - 'paginate' => [], |
|
143 | - 'paginateby' => [], |
|
144 | - 'first' => [], |
|
145 | - 'search' => [], |
|
146 | - 'deleted' => [], |
|
147 | - ] |
|
148 | - ], |
|
69 | + 'relations' => [ |
|
70 | + 'users' => [ |
|
71 | + 'list' => [], |
|
72 | + 'find' => [], |
|
73 | + 'findby' => [], |
|
74 | + 'paginate' => [], |
|
75 | + 'paginateby' => [], |
|
76 | + 'first' => [], |
|
77 | + 'search' => [], |
|
78 | + 'account' => [], |
|
79 | + 'group' => [], |
|
80 | + 'deleted' => [], |
|
81 | + ], |
|
82 | + 'permissions' => [ |
|
83 | + 'list' => [], |
|
84 | + 'find' => [], |
|
85 | + 'findby' => [], |
|
86 | + 'paginate' => [], |
|
87 | + 'paginateby' => [], |
|
88 | + 'first' => [], |
|
89 | + 'search' => [], |
|
90 | + 'deleted' => [], |
|
91 | + ], |
|
92 | + 'groups' => [ |
|
93 | + 'list' => [], |
|
94 | + 'find' => [], |
|
95 | + 'findby' => [], |
|
96 | + 'paginate' => [], |
|
97 | + 'paginateby' => [], |
|
98 | + 'first' => [], |
|
99 | + 'search' => [], |
|
100 | + 'deleted' => [], |
|
101 | + ], |
|
102 | + 'oauthClients' => [ |
|
103 | + 'list' => [], |
|
104 | + 'find' => [], |
|
105 | + 'findby' => [], |
|
106 | + 'paginate' => [], |
|
107 | + 'paginateby' => [], |
|
108 | + 'first' => [], |
|
109 | + 'search' => [], |
|
110 | + 'account' => [], |
|
111 | + 'group' => [], |
|
112 | + 'deleted' => [], |
|
113 | + ], |
|
114 | + 'notifications' => [ |
|
115 | + 'list' => [], |
|
116 | + 'unread' => [], |
|
117 | + ], |
|
118 | + 'pushNotificationDevices' => [ |
|
119 | + 'list' => [], |
|
120 | + 'find' => [], |
|
121 | + 'findby' => [], |
|
122 | + 'paginate' => [], |
|
123 | + 'paginateby' => [], |
|
124 | + 'first' => [], |
|
125 | + 'search' => [], |
|
126 | + 'deleted' => [], |
|
127 | + ], |
|
128 | + 'reports' => [ |
|
129 | + 'list' => [], |
|
130 | + 'find' => [], |
|
131 | + 'findby' => [], |
|
132 | + 'paginate' => [], |
|
133 | + 'paginateby' => [], |
|
134 | + 'first' => [], |
|
135 | + 'search' => [], |
|
136 | + 'deleted' => [], |
|
137 | + ], |
|
138 | + 'settings' => [ |
|
139 | + 'list' => [], |
|
140 | + 'find' => [], |
|
141 | + 'findby' => [], |
|
142 | + 'paginate' => [], |
|
143 | + 'paginateby' => [], |
|
144 | + 'first' => [], |
|
145 | + 'search' => [], |
|
146 | + 'deleted' => [], |
|
147 | + ] |
|
148 | + ], |
|
149 | 149 | |
150 | - /* |
|
150 | + /* |
|
151 | 151 | |-------------------------------------------------------------------------- |
152 | 152 | | Cache Configurations |
153 | 153 | |-------------------------------------------------------------------------- |
@@ -156,46 +156,46 @@ discard block |
||
156 | 156 | | |
157 | 157 | */ |
158 | 158 | |
159 | - 'cache_config' => [ |
|
160 | - 'oauthClients' => [ |
|
161 | - 'cache' => [ |
|
162 | - 'all', |
|
163 | - 'find', |
|
164 | - 'findBy', |
|
165 | - 'paginate', |
|
166 | - 'paginateBy', |
|
167 | - 'first', |
|
168 | - 'search', |
|
169 | - 'deleted' |
|
170 | - ], |
|
171 | - 'clear' => [ |
|
172 | - 'update' => ['oauthClients', 'users', 'groups'], |
|
173 | - 'save' => ['oauthClients', 'users', 'groups'], |
|
174 | - 'delete' => ['oauthClients', 'users', 'groups'], |
|
175 | - 'restore' => ['oauthClients', 'users', 'groups'], |
|
176 | - 'revoke' => ['oauthClients', 'users', 'groups'], |
|
177 | - 'ubRevoke' => ['oauthClients', 'users', 'groups'], |
|
178 | - 'regenerateSecret' => ['oauthClients', 'users', 'groups'], |
|
179 | - ], |
|
180 | - ], |
|
181 | - 'settings' => [ |
|
182 | - 'cache' => [ |
|
183 | - 'all', |
|
184 | - 'find', |
|
185 | - 'findBy', |
|
186 | - 'paginate', |
|
187 | - 'paginateBy', |
|
188 | - 'first', |
|
189 | - 'search', |
|
190 | - 'deleted' |
|
191 | - ], |
|
192 | - 'clear' => [ |
|
193 | - 'update' => ['settings'], |
|
194 | - 'save' => ['settings'], |
|
195 | - 'delete' => ['settings'], |
|
196 | - 'restore' => ['settings'], |
|
197 | - 'saveMany' => ['settings'], |
|
198 | - ] |
|
199 | - ] |
|
200 | - ] |
|
159 | + 'cache_config' => [ |
|
160 | + 'oauthClients' => [ |
|
161 | + 'cache' => [ |
|
162 | + 'all', |
|
163 | + 'find', |
|
164 | + 'findBy', |
|
165 | + 'paginate', |
|
166 | + 'paginateBy', |
|
167 | + 'first', |
|
168 | + 'search', |
|
169 | + 'deleted' |
|
170 | + ], |
|
171 | + 'clear' => [ |
|
172 | + 'update' => ['oauthClients', 'users', 'groups'], |
|
173 | + 'save' => ['oauthClients', 'users', 'groups'], |
|
174 | + 'delete' => ['oauthClients', 'users', 'groups'], |
|
175 | + 'restore' => ['oauthClients', 'users', 'groups'], |
|
176 | + 'revoke' => ['oauthClients', 'users', 'groups'], |
|
177 | + 'ubRevoke' => ['oauthClients', 'users', 'groups'], |
|
178 | + 'regenerateSecret' => ['oauthClients', 'users', 'groups'], |
|
179 | + ], |
|
180 | + ], |
|
181 | + 'settings' => [ |
|
182 | + 'cache' => [ |
|
183 | + 'all', |
|
184 | + 'find', |
|
185 | + 'findBy', |
|
186 | + 'paginate', |
|
187 | + 'paginateBy', |
|
188 | + 'first', |
|
189 | + 'search', |
|
190 | + 'deleted' |
|
191 | + ], |
|
192 | + 'clear' => [ |
|
193 | + 'update' => ['settings'], |
|
194 | + 'save' => ['settings'], |
|
195 | + 'delete' => ['settings'], |
|
196 | + 'restore' => ['settings'], |
|
197 | + 'saveMany' => ['settings'], |
|
198 | + ] |
|
199 | + ] |
|
200 | + ] |
|
201 | 201 | ]; |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | class CoreConfig |
4 | 4 | { |
5 | - public function getConfig() |
|
6 | - { |
|
7 | - return [ |
|
5 | + public function getConfig() |
|
6 | + { |
|
7 | + return [ |
|
8 | 8 | /** |
9 | 9 | * Specify what relations should be used for every model. |
10 | 10 | */ |
@@ -14,5 +14,5 @@ discard block |
||
14 | 14 | */ |
15 | 15 | 'cacheConfig' => config('cache_config'), |
16 | 16 | ]; |
17 | - } |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -2,27 +2,27 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /** |
|
6 | - * List of error messages used in core module. |
|
7 | - */ |
|
8 | - 'unAuthorized' => 'Please login before any action', |
|
9 | - 'invalidRefreshToken' => 'Invalid refresh token', |
|
10 | - 'noPermissions' => 'No permissions', |
|
11 | - 'loginFailed' => 'Wrong mail or password', |
|
12 | - 'noSocialEmail' => 'Couldn\'t retrieve email', |
|
13 | - 'userAlreadyRegistered' => 'User already registered. Please login using email and password', |
|
14 | - 'connectionError' => 'Connection error', |
|
15 | - 'redisNotRunning' => 'Your redis notification server is\'t running', |
|
16 | - 'dbQueryError' => 'Please check the given inputes', |
|
17 | - 'cannotCreateSetting' => 'Can\'t create setting', |
|
18 | - 'cannotUpdateSettingKey' => 'Can\'t update setting key', |
|
19 | - 'userIsBlocked' => 'You have been blocked', |
|
20 | - 'invalidResetToken' => 'Reset password token is invalid', |
|
21 | - 'invalidResetPassword' => 'Reset password is invalid', |
|
22 | - 'invalidOldPassword' => 'Old password is invalid', |
|
23 | - 'notFound' => 'The requested :replace not found', |
|
24 | - 'generalError' => 'Something went wrong', |
|
25 | - 'emailNotConfirmed' => 'Your email isn\'t confirmed', |
|
26 | - 'emailAlreadyConfirmed' => 'Your email is already confirmed' |
|
5 | + /** |
|
6 | + * List of error messages used in core module. |
|
7 | + */ |
|
8 | + 'unAuthorized' => 'Please login before any action', |
|
9 | + 'invalidRefreshToken' => 'Invalid refresh token', |
|
10 | + 'noPermissions' => 'No permissions', |
|
11 | + 'loginFailed' => 'Wrong mail or password', |
|
12 | + 'noSocialEmail' => 'Couldn\'t retrieve email', |
|
13 | + 'userAlreadyRegistered' => 'User already registered. Please login using email and password', |
|
14 | + 'connectionError' => 'Connection error', |
|
15 | + 'redisNotRunning' => 'Your redis notification server is\'t running', |
|
16 | + 'dbQueryError' => 'Please check the given inputes', |
|
17 | + 'cannotCreateSetting' => 'Can\'t create setting', |
|
18 | + 'cannotUpdateSettingKey' => 'Can\'t update setting key', |
|
19 | + 'userIsBlocked' => 'You have been blocked', |
|
20 | + 'invalidResetToken' => 'Reset password token is invalid', |
|
21 | + 'invalidResetPassword' => 'Reset password is invalid', |
|
22 | + 'invalidOldPassword' => 'Old password is invalid', |
|
23 | + 'notFound' => 'The requested :replace not found', |
|
24 | + 'generalError' => 'Something went wrong', |
|
25 | + 'emailNotConfirmed' => 'Your email isn\'t confirmed', |
|
26 | + 'emailAlreadyConfirmed' => 'Your email is already confirmed' |
|
27 | 27 | |
28 | 28 | ]; |
29 | 29 | \ No newline at end of file |
@@ -2,27 +2,27 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /** |
|
6 | - * List of error messages used in core module. |
|
7 | - */ |
|
8 | - 'unAuthorized' => 'من فضلك قم بتسجيل الدخول', |
|
9 | - 'invalidRefreshToken' => 'رمز التحديث غير صالح', |
|
10 | - 'noPermissions' => 'لا توجد صلاحية', |
|
11 | - 'loginFailed' => 'خطأ في البريد لاكتروني او كلمة المرور', |
|
12 | - 'noSocialEmail' => 'لا يمكن الحصول علي تابريد الاكتروني', |
|
13 | - 'userAlreadyRegistered' => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر', |
|
14 | - 'connectionError' => 'خطأ في الاتصال', |
|
15 | - 'redisNotRunning' => 'سيرفير الاشعارات لايعمل', |
|
16 | - 'dbQueryError' => 'خطا في البيانات', |
|
17 | - 'cannotCreateSetting' => 'لا يمكن اضافة اعدادات', |
|
18 | - 'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات', |
|
19 | - 'userIsBlocked' => 'لقد تم حظرك', |
|
20 | - 'invalidResetToken' => 'رمز تعديل كلمة المرور خطا', |
|
21 | - 'invalidResetPassword' => 'خطا في نعديل كلمة المرور', |
|
22 | - 'invalidOldPassword' => 'كلمة السر القديمه خطا', |
|
23 | - 'notFound' => 'ال :replace المطلوب غير موجود', |
|
24 | - 'generalError' => 'حدث خطا ما', |
|
25 | - 'emailNotConfirmed' => 'بريدك الاكتروني غير مفعل', |
|
26 | - 'emailAlreadyConfirmed' => 'البريد الاكتروني مفع بالقعل' |
|
5 | + /** |
|
6 | + * List of error messages used in core module. |
|
7 | + */ |
|
8 | + 'unAuthorized' => 'من فضلك قم بتسجيل الدخول', |
|
9 | + 'invalidRefreshToken' => 'رمز التحديث غير صالح', |
|
10 | + 'noPermissions' => 'لا توجد صلاحية', |
|
11 | + 'loginFailed' => 'خطأ في البريد لاكتروني او كلمة المرور', |
|
12 | + 'noSocialEmail' => 'لا يمكن الحصول علي تابريد الاكتروني', |
|
13 | + 'userAlreadyRegistered' => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر', |
|
14 | + 'connectionError' => 'خطأ في الاتصال', |
|
15 | + 'redisNotRunning' => 'سيرفير الاشعارات لايعمل', |
|
16 | + 'dbQueryError' => 'خطا في البيانات', |
|
17 | + 'cannotCreateSetting' => 'لا يمكن اضافة اعدادات', |
|
18 | + 'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات', |
|
19 | + 'userIsBlocked' => 'لقد تم حظرك', |
|
20 | + 'invalidResetToken' => 'رمز تعديل كلمة المرور خطا', |
|
21 | + 'invalidResetPassword' => 'خطا في نعديل كلمة المرور', |
|
22 | + 'invalidOldPassword' => 'كلمة السر القديمه خطا', |
|
23 | + 'notFound' => 'ال :replace المطلوب غير موجود', |
|
24 | + 'generalError' => 'حدث خطا ما', |
|
25 | + 'emailNotConfirmed' => 'بريدك الاكتروني غير مفعل', |
|
26 | + 'emailAlreadyConfirmed' => 'البريد الاكتروني مفع بالقعل' |
|
27 | 27 | |
28 | 28 | ]; |
29 | 29 | \ No newline at end of file |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /** |
|
6 | - * Here goes your notification messages. |
|
7 | - */ |
|
5 | + /** |
|
6 | + * Here goes your notification messages. |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | ]; |
10 | 10 | \ No newline at end of file |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /** |
|
6 | - * Here goes your notification messages. |
|
7 | - */ |
|
5 | + /** |
|
6 | + * Here goes your notification messages. |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | ]; |
10 | 10 | \ No newline at end of file |
@@ -10,43 +10,43 @@ |
||
10 | 10 | |
11 | 11 | class ResetPassword extends Notification implements ShouldQueue |
12 | 12 | { |
13 | - use Queueable; |
|
13 | + use Queueable; |
|
14 | 14 | |
15 | - protected $token; |
|
15 | + protected $token; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Create a new notification instance. |
|
19 | - * |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function __construct($token) |
|
23 | - { |
|
24 | - $this->token = $token; |
|
25 | - } |
|
17 | + /** |
|
18 | + * Create a new notification instance. |
|
19 | + * |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function __construct($token) |
|
23 | + { |
|
24 | + $this->token = $token; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Get the notification's delivery channels. |
|
29 | - * |
|
30 | - * @param mixed $notifiable |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function via($notifiable) |
|
34 | - { |
|
35 | - return ['mail']; |
|
36 | - } |
|
27 | + /** |
|
28 | + * Get the notification's delivery channels. |
|
29 | + * |
|
30 | + * @param mixed $notifiable |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function via($notifiable) |
|
34 | + { |
|
35 | + return ['mail']; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get the mail representation of the notification. |
|
40 | - * |
|
41 | - * @param mixed $notifiable |
|
42 | - * @return \Illuminate\Notifications\Messages\MailMessage |
|
43 | - */ |
|
44 | - public function toMail($notifiable) |
|
45 | - { |
|
46 | - return (new MailMessage) |
|
47 | - ->subject('Reset passowrd') |
|
48 | - ->line('Reset passowrd') |
|
49 | - ->line('To reset your password click on the button below') |
|
50 | - ->action('Reset password', config('reset_password_url') . '/' . $this->token); |
|
51 | - } |
|
38 | + /** |
|
39 | + * Get the mail representation of the notification. |
|
40 | + * |
|
41 | + * @param mixed $notifiable |
|
42 | + * @return \Illuminate\Notifications\Messages\MailMessage |
|
43 | + */ |
|
44 | + public function toMail($notifiable) |
|
45 | + { |
|
46 | + return (new MailMessage) |
|
47 | + ->subject('Reset passowrd') |
|
48 | + ->line('Reset passowrd') |
|
49 | + ->line('To reset your password click on the button below') |
|
50 | + ->action('Reset password', config('reset_password_url') . '/' . $this->token); |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -5,394 +5,394 @@ |
||
5 | 5 | |
6 | 6 | class UserRepository extends AbstractRepository |
7 | 7 | { |
8 | - /** |
|
9 | - * Return the model full namespace. |
|
10 | - * |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - protected function getModel() |
|
14 | - { |
|
15 | - return 'App\Modules\Acl\AclUser'; |
|
16 | - } |
|
17 | - |
|
18 | - |
|
19 | - /** |
|
20 | - * Return the logged in user account. |
|
21 | - * |
|
22 | - * @param array $relations |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function account($relations = []) |
|
26 | - { |
|
27 | - $permissions = []; |
|
28 | - $user = \Core::users()->find(\Auth::id(), $relations); |
|
29 | - foreach ($user->groups()->get() as $group) |
|
30 | - { |
|
31 | - $group->permissions->each(function ($permission) use (&$permissions){ |
|
32 | - $permissions[$permission->model][$permission->id] = $permission->name; |
|
33 | - }); |
|
34 | - } |
|
35 | - $user->permissions = $permissions; |
|
36 | - |
|
37 | - return $user; |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Check if the logged in user or the given user |
|
42 | - * has the given permissions on the given model. |
|
43 | - * |
|
44 | - * @param string $nameOfPermission |
|
45 | - * @param string $model |
|
46 | - * @param boolean $user |
|
47 | - * @return boolean |
|
48 | - */ |
|
49 | - public function can($nameOfPermission, $model, $user = false) |
|
50 | - { |
|
51 | - $user = $user ?: $this->find(\Auth::id(), ['groups.permissions']); |
|
52 | - $permissions = []; |
|
53 | - |
|
54 | - $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){ |
|
55 | - $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
|
56 | - }); |
|
8 | + /** |
|
9 | + * Return the model full namespace. |
|
10 | + * |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + protected function getModel() |
|
14 | + { |
|
15 | + return 'App\Modules\Acl\AclUser'; |
|
16 | + } |
|
17 | + |
|
18 | + |
|
19 | + /** |
|
20 | + * Return the logged in user account. |
|
21 | + * |
|
22 | + * @param array $relations |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function account($relations = []) |
|
26 | + { |
|
27 | + $permissions = []; |
|
28 | + $user = \Core::users()->find(\Auth::id(), $relations); |
|
29 | + foreach ($user->groups()->get() as $group) |
|
30 | + { |
|
31 | + $group->permissions->each(function ($permission) use (&$permissions){ |
|
32 | + $permissions[$permission->model][$permission->id] = $permission->name; |
|
33 | + }); |
|
34 | + } |
|
35 | + $user->permissions = $permissions; |
|
36 | + |
|
37 | + return $user; |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * Check if the logged in user or the given user |
|
42 | + * has the given permissions on the given model. |
|
43 | + * |
|
44 | + * @param string $nameOfPermission |
|
45 | + * @param string $model |
|
46 | + * @param boolean $user |
|
47 | + * @return boolean |
|
48 | + */ |
|
49 | + public function can($nameOfPermission, $model, $user = false) |
|
50 | + { |
|
51 | + $user = $user ?: $this->find(\Auth::id(), ['groups.permissions']); |
|
52 | + $permissions = []; |
|
53 | + |
|
54 | + $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){ |
|
55 | + $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
|
56 | + }); |
|
57 | 57 | |
58 | - return in_array($nameOfPermission, $permissions); |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Check if the logged in user has the given group. |
|
63 | - * |
|
64 | - * @param string $groupName |
|
65 | - * @param integer $userId |
|
66 | - * @return boolean |
|
67 | - */ |
|
68 | - public function hasGroup($groups, $user = false) |
|
69 | - { |
|
70 | - $user = $user ?: $this->find(\Auth::id()); |
|
71 | - return $user->groups->whereIn('name', $groups)->count() ? true : false; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Assign the given group ids to the given user. |
|
76 | - * |
|
77 | - * @param integer $user_id |
|
78 | - * @param array $group_ids |
|
79 | - * @return object |
|
80 | - */ |
|
81 | - public function assignGroups($user_id, $group_ids) |
|
82 | - { |
|
83 | - \DB::transaction(function () use ($user_id, $group_ids) { |
|
84 | - $user = $this->find($user_id); |
|
85 | - $user->groups()->detach(); |
|
86 | - $user->groups()->attach($group_ids); |
|
87 | - }); |
|
88 | - |
|
89 | - return $this->find($user_id); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Handle a login request to the application. |
|
95 | - * |
|
96 | - * @param array $credentials |
|
97 | - * @param boolean $adminLogin |
|
98 | - * @return object |
|
99 | - */ |
|
100 | - public function login($credentials, $adminLogin = false) |
|
101 | - { |
|
102 | - if ( ! $user = $this->first(['email' => $credentials['email']])) |
|
103 | - { |
|
104 | - \ErrorHandler::loginFailed(); |
|
105 | - } |
|
106 | - else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
107 | - { |
|
108 | - \ErrorHandler::loginFailed(); |
|
109 | - } |
|
110 | - else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
111 | - { |
|
112 | - \ErrorHandler::loginFailed(); |
|
113 | - } |
|
114 | - else if ($user->blocked) |
|
115 | - { |
|
116 | - \ErrorHandler::userIsBlocked(); |
|
117 | - } |
|
118 | - else if ( ! config('disable_confirm_email') && ! $user->confirmed) |
|
119 | - { |
|
120 | - \ErrorHandler::emailNotConfirmed(); |
|
121 | - } |
|
122 | - |
|
123 | - return $user; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Handle a social login request of the none admin to the application. |
|
128 | - * |
|
129 | - * @param array $credentials |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - public function loginSocial($credentials) |
|
133 | - { |
|
134 | - $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token']; |
|
135 | - $user = \Socialite::driver($credentials['type'])->userFromToken($access_token); |
|
136 | - |
|
137 | - if ( ! $user->email) |
|
138 | - { |
|
139 | - \ErrorHandler::noSocialEmail(); |
|
140 | - } |
|
141 | - |
|
142 | - if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) |
|
143 | - { |
|
144 | - $data = ['email' => $user->email, 'password' => '']; |
|
145 | - return $this->register($data); |
|
146 | - } |
|
147 | - else |
|
148 | - { |
|
149 | - if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
|
150 | - { |
|
151 | - \ErrorHandler::userAlreadyRegistered(); |
|
152 | - } |
|
153 | - |
|
154 | - $loginProxy = \App::make('App\Modules\Acl\Proxy\LoginProxy'); |
|
155 | - return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0); |
|
156 | - } |
|
157 | - } |
|
58 | + return in_array($nameOfPermission, $permissions); |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Check if the logged in user has the given group. |
|
63 | + * |
|
64 | + * @param string $groupName |
|
65 | + * @param integer $userId |
|
66 | + * @return boolean |
|
67 | + */ |
|
68 | + public function hasGroup($groups, $user = false) |
|
69 | + { |
|
70 | + $user = $user ?: $this->find(\Auth::id()); |
|
71 | + return $user->groups->whereIn('name', $groups)->count() ? true : false; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Assign the given group ids to the given user. |
|
76 | + * |
|
77 | + * @param integer $user_id |
|
78 | + * @param array $group_ids |
|
79 | + * @return object |
|
80 | + */ |
|
81 | + public function assignGroups($user_id, $group_ids) |
|
82 | + { |
|
83 | + \DB::transaction(function () use ($user_id, $group_ids) { |
|
84 | + $user = $this->find($user_id); |
|
85 | + $user->groups()->detach(); |
|
86 | + $user->groups()->attach($group_ids); |
|
87 | + }); |
|
88 | + |
|
89 | + return $this->find($user_id); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Handle a login request to the application. |
|
95 | + * |
|
96 | + * @param array $credentials |
|
97 | + * @param boolean $adminLogin |
|
98 | + * @return object |
|
99 | + */ |
|
100 | + public function login($credentials, $adminLogin = false) |
|
101 | + { |
|
102 | + if ( ! $user = $this->first(['email' => $credentials['email']])) |
|
103 | + { |
|
104 | + \ErrorHandler::loginFailed(); |
|
105 | + } |
|
106 | + else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) |
|
107 | + { |
|
108 | + \ErrorHandler::loginFailed(); |
|
109 | + } |
|
110 | + else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) |
|
111 | + { |
|
112 | + \ErrorHandler::loginFailed(); |
|
113 | + } |
|
114 | + else if ($user->blocked) |
|
115 | + { |
|
116 | + \ErrorHandler::userIsBlocked(); |
|
117 | + } |
|
118 | + else if ( ! config('disable_confirm_email') && ! $user->confirmed) |
|
119 | + { |
|
120 | + \ErrorHandler::emailNotConfirmed(); |
|
121 | + } |
|
122 | + |
|
123 | + return $user; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Handle a social login request of the none admin to the application. |
|
128 | + * |
|
129 | + * @param array $credentials |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + public function loginSocial($credentials) |
|
133 | + { |
|
134 | + $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token']; |
|
135 | + $user = \Socialite::driver($credentials['type'])->userFromToken($access_token); |
|
136 | + |
|
137 | + if ( ! $user->email) |
|
138 | + { |
|
139 | + \ErrorHandler::noSocialEmail(); |
|
140 | + } |
|
141 | + |
|
142 | + if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) |
|
143 | + { |
|
144 | + $data = ['email' => $user->email, 'password' => '']; |
|
145 | + return $this->register($data); |
|
146 | + } |
|
147 | + else |
|
148 | + { |
|
149 | + if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
|
150 | + { |
|
151 | + \ErrorHandler::userAlreadyRegistered(); |
|
152 | + } |
|
153 | + |
|
154 | + $loginProxy = \App::make('App\Modules\Acl\Proxy\LoginProxy'); |
|
155 | + return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0); |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Handle a registration request. |
|
161 | - * |
|
162 | - * @param array $credentials |
|
163 | - * @return array |
|
164 | - */ |
|
165 | - public function register($credentials) |
|
166 | - { |
|
167 | - $user = $this->save($credentials); |
|
168 | - |
|
169 | - if ( ! config('disable_confirm_email')) |
|
170 | - { |
|
171 | - $this->sendConfirmationEmail($user->email); |
|
172 | - } |
|
173 | - } |
|
159 | + /** |
|
160 | + * Handle a registration request. |
|
161 | + * |
|
162 | + * @param array $credentials |
|
163 | + * @return array |
|
164 | + */ |
|
165 | + public function register($credentials) |
|
166 | + { |
|
167 | + $user = $this->save($credentials); |
|
168 | + |
|
169 | + if ( ! config('disable_confirm_email')) |
|
170 | + { |
|
171 | + $this->sendConfirmationEmail($user->email); |
|
172 | + } |
|
173 | + } |
|
174 | 174 | |
175 | - /** |
|
176 | - * Block the user. |
|
177 | - * |
|
178 | - * @param integer $user_id |
|
179 | - * @return object |
|
180 | - */ |
|
181 | - public function block($user_id) |
|
182 | - { |
|
183 | - if ( ! $user = $this->find($user_id)) |
|
184 | - { |
|
185 | - \ErrorHandler::notFound('user'); |
|
186 | - } |
|
187 | - if ( ! $this->hasGroup(['Admin'])) |
|
188 | - { |
|
189 | - \ErrorHandler::noPermissions(); |
|
190 | - } |
|
191 | - else if (\Auth::id() == $user_id) |
|
192 | - { |
|
193 | - \ErrorHandler::noPermissions(); |
|
194 | - } |
|
195 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
196 | - { |
|
197 | - \ErrorHandler::noPermissions(); |
|
198 | - } |
|
199 | - |
|
200 | - $user->blocked = 1; |
|
201 | - $user->save(); |
|
175 | + /** |
|
176 | + * Block the user. |
|
177 | + * |
|
178 | + * @param integer $user_id |
|
179 | + * @return object |
|
180 | + */ |
|
181 | + public function block($user_id) |
|
182 | + { |
|
183 | + if ( ! $user = $this->find($user_id)) |
|
184 | + { |
|
185 | + \ErrorHandler::notFound('user'); |
|
186 | + } |
|
187 | + if ( ! $this->hasGroup(['Admin'])) |
|
188 | + { |
|
189 | + \ErrorHandler::noPermissions(); |
|
190 | + } |
|
191 | + else if (\Auth::id() == $user_id) |
|
192 | + { |
|
193 | + \ErrorHandler::noPermissions(); |
|
194 | + } |
|
195 | + else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
196 | + { |
|
197 | + \ErrorHandler::noPermissions(); |
|
198 | + } |
|
199 | + |
|
200 | + $user->blocked = 1; |
|
201 | + $user->save(); |
|
202 | 202 | |
203 | - return $user; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Unblock the user. |
|
208 | - * |
|
209 | - * @param integer $user_id |
|
210 | - * @return object |
|
211 | - */ |
|
212 | - public function unblock($user_id) |
|
213 | - { |
|
214 | - if ( ! $this->hasGroup(['Admin'])) |
|
215 | - { |
|
216 | - \ErrorHandler::noPermissions(); |
|
217 | - } |
|
218 | - |
|
219 | - $user = $this->find($user_id); |
|
220 | - $user->blocked = 0; |
|
221 | - $user->save(); |
|
222 | - |
|
223 | - return $user; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Send a reset link to the given user. |
|
228 | - * |
|
229 | - * @param string $email |
|
230 | - * @return void |
|
231 | - */ |
|
232 | - public function sendReset($email) |
|
233 | - { |
|
234 | - if ( ! $user = $this->model->where('email', $email)->first()) |
|
235 | - { |
|
236 | - \ErrorHandler::notFound('email'); |
|
237 | - } |
|
238 | - |
|
239 | - $token = \Password::getRepository()->create($user); |
|
240 | - \Core::notifications()->notify($user, 'ResetPassword', $token); |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Reset the given user's password. |
|
245 | - * |
|
246 | - * @param array $credentials |
|
247 | - * @return array |
|
248 | - */ |
|
249 | - public function resetPassword($credentials) |
|
250 | - { |
|
251 | - $response = \Password::reset($credentials, function ($user, $password) { |
|
252 | - $user->password = $password; |
|
253 | - $user->save(); |
|
254 | - }); |
|
255 | - |
|
256 | - switch ($response) { |
|
257 | - case \Password::PASSWORD_RESET: |
|
258 | - return 'success'; |
|
203 | + return $user; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Unblock the user. |
|
208 | + * |
|
209 | + * @param integer $user_id |
|
210 | + * @return object |
|
211 | + */ |
|
212 | + public function unblock($user_id) |
|
213 | + { |
|
214 | + if ( ! $this->hasGroup(['Admin'])) |
|
215 | + { |
|
216 | + \ErrorHandler::noPermissions(); |
|
217 | + } |
|
218 | + |
|
219 | + $user = $this->find($user_id); |
|
220 | + $user->blocked = 0; |
|
221 | + $user->save(); |
|
222 | + |
|
223 | + return $user; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Send a reset link to the given user. |
|
228 | + * |
|
229 | + * @param string $email |
|
230 | + * @return void |
|
231 | + */ |
|
232 | + public function sendReset($email) |
|
233 | + { |
|
234 | + if ( ! $user = $this->model->where('email', $email)->first()) |
|
235 | + { |
|
236 | + \ErrorHandler::notFound('email'); |
|
237 | + } |
|
238 | + |
|
239 | + $token = \Password::getRepository()->create($user); |
|
240 | + \Core::notifications()->notify($user, 'ResetPassword', $token); |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Reset the given user's password. |
|
245 | + * |
|
246 | + * @param array $credentials |
|
247 | + * @return array |
|
248 | + */ |
|
249 | + public function resetPassword($credentials) |
|
250 | + { |
|
251 | + $response = \Password::reset($credentials, function ($user, $password) { |
|
252 | + $user->password = $password; |
|
253 | + $user->save(); |
|
254 | + }); |
|
255 | + |
|
256 | + switch ($response) { |
|
257 | + case \Password::PASSWORD_RESET: |
|
258 | + return 'success'; |
|
259 | 259 | |
260 | - case \Password::INVALID_TOKEN: |
|
261 | - \ErrorHandler::invalidResetToken('token'); |
|
262 | - |
|
263 | - case \Password::INVALID_PASSWORD: |
|
264 | - \ErrorHandler::invalidResetPassword('email'); |
|
265 | - |
|
266 | - case \Password::INVALID_USER: |
|
267 | - \ErrorHandler::notFound('user'); |
|
268 | - |
|
269 | - default: |
|
270 | - \ErrorHandler::generalError(); |
|
271 | - } |
|
272 | - } |
|
273 | - |
|
274 | - /** |
|
275 | - * Change the logged in user password. |
|
276 | - * |
|
277 | - * @param array $credentials |
|
278 | - * @return void |
|
279 | - */ |
|
280 | - public function changePassword($credentials) |
|
281 | - { |
|
282 | - $user = \Auth::user(); |
|
283 | - if ( ! \Hash::check($credentials['old_password'], $user->password)) |
|
284 | - { |
|
285 | - \ErrorHandler::invalidOldPassword(); |
|
286 | - } |
|
287 | - |
|
288 | - $user->password = $credentials['password']; |
|
289 | - $user->save(); |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * Confirm email using the confirmation code. |
|
294 | - * |
|
295 | - * @param string $confirmationCode |
|
296 | - * @return void |
|
297 | - */ |
|
298 | - public function confirmEmail($confirmationCode) |
|
299 | - { |
|
300 | - $user = $this->first(['confirmation_code' => $confirmationCode]); |
|
301 | - $user->confirmed = 1; |
|
302 | - $user->confirmation_code = null; |
|
303 | - $user->save(); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Send the confirmation mail. |
|
308 | - * |
|
309 | - * @param string $email |
|
310 | - * @return void |
|
311 | - */ |
|
312 | - public function sendConfirmationEmail($email) |
|
313 | - { |
|
314 | - $user = $this->first(['email' => $email]); |
|
315 | - if ($user->confirmed) |
|
316 | - { |
|
317 | - \ErrorHandler::emailAlreadyConfirmed(); |
|
318 | - } |
|
319 | - |
|
320 | - $user->confirmed = 0; |
|
321 | - $user->confirmation_code = sha1(microtime()); |
|
322 | - $user->save(); |
|
323 | - \Core::notifications()->notify($user, 'ConfirmEmail'); |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Paginate all users in the given group based on the given conditions. |
|
328 | - * |
|
329 | - * @param string $groupName |
|
330 | - * @param array $relations |
|
331 | - * @param integer $perPage |
|
332 | - * @param string $sortBy |
|
333 | - * @param boolean $desc |
|
334 | - * @return \Illuminate\Http\Response |
|
335 | - */ |
|
336 | - public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc) |
|
337 | - { |
|
338 | - unset($conditions['page']); |
|
339 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
340 | - $sort = $desc ? 'desc' : 'asc'; |
|
341 | - $model = call_user_func_array("{$this->getModel()}::with", array($relations)); |
|
342 | - |
|
343 | - $model->whereHas('groups', function($q) use ($groupName){ |
|
344 | - $q->where('name', $groupName); |
|
345 | - }); |
|
260 | + case \Password::INVALID_TOKEN: |
|
261 | + \ErrorHandler::invalidResetToken('token'); |
|
262 | + |
|
263 | + case \Password::INVALID_PASSWORD: |
|
264 | + \ErrorHandler::invalidResetPassword('email'); |
|
265 | + |
|
266 | + case \Password::INVALID_USER: |
|
267 | + \ErrorHandler::notFound('user'); |
|
268 | + |
|
269 | + default: |
|
270 | + \ErrorHandler::generalError(); |
|
271 | + } |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Change the logged in user password. |
|
276 | + * |
|
277 | + * @param array $credentials |
|
278 | + * @return void |
|
279 | + */ |
|
280 | + public function changePassword($credentials) |
|
281 | + { |
|
282 | + $user = \Auth::user(); |
|
283 | + if ( ! \Hash::check($credentials['old_password'], $user->password)) |
|
284 | + { |
|
285 | + \ErrorHandler::invalidOldPassword(); |
|
286 | + } |
|
287 | + |
|
288 | + $user->password = $credentials['password']; |
|
289 | + $user->save(); |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * Confirm email using the confirmation code. |
|
294 | + * |
|
295 | + * @param string $confirmationCode |
|
296 | + * @return void |
|
297 | + */ |
|
298 | + public function confirmEmail($confirmationCode) |
|
299 | + { |
|
300 | + $user = $this->first(['confirmation_code' => $confirmationCode]); |
|
301 | + $user->confirmed = 1; |
|
302 | + $user->confirmation_code = null; |
|
303 | + $user->save(); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Send the confirmation mail. |
|
308 | + * |
|
309 | + * @param string $email |
|
310 | + * @return void |
|
311 | + */ |
|
312 | + public function sendConfirmationEmail($email) |
|
313 | + { |
|
314 | + $user = $this->first(['email' => $email]); |
|
315 | + if ($user->confirmed) |
|
316 | + { |
|
317 | + \ErrorHandler::emailAlreadyConfirmed(); |
|
318 | + } |
|
319 | + |
|
320 | + $user->confirmed = 0; |
|
321 | + $user->confirmation_code = sha1(microtime()); |
|
322 | + $user->save(); |
|
323 | + \Core::notifications()->notify($user, 'ConfirmEmail'); |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Paginate all users in the given group based on the given conditions. |
|
328 | + * |
|
329 | + * @param string $groupName |
|
330 | + * @param array $relations |
|
331 | + * @param integer $perPage |
|
332 | + * @param string $sortBy |
|
333 | + * @param boolean $desc |
|
334 | + * @return \Illuminate\Http\Response |
|
335 | + */ |
|
336 | + public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc) |
|
337 | + { |
|
338 | + unset($conditions['page']); |
|
339 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
340 | + $sort = $desc ? 'desc' : 'asc'; |
|
341 | + $model = call_user_func_array("{$this->getModel()}::with", array($relations)); |
|
342 | + |
|
343 | + $model->whereHas('groups', function($q) use ($groupName){ |
|
344 | + $q->where('name', $groupName); |
|
345 | + }); |
|
346 | 346 | |
347 | 347 | |
348 | - if (count($conditions['conditionValues'])) |
|
349 | - { |
|
350 | - $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
351 | - } |
|
352 | - |
|
353 | - if ($perPage) |
|
354 | - { |
|
355 | - return $model->orderBy($sortBy, $sort)->paginate($perPage); |
|
356 | - } |
|
357 | - |
|
358 | - return $model->orderBy($sortBy, $sort)->get(); |
|
359 | - } |
|
360 | - |
|
361 | - /** |
|
362 | - * Save the given data to the logged in user. |
|
363 | - * |
|
364 | - * @param array $credentials |
|
365 | - * @return void |
|
366 | - */ |
|
367 | - public function saveProfile($data) |
|
368 | - { |
|
369 | - if (array_key_exists('profile_picture', $data)) |
|
370 | - { |
|
371 | - $data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures'); |
|
372 | - } |
|
348 | + if (count($conditions['conditionValues'])) |
|
349 | + { |
|
350 | + $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
351 | + } |
|
352 | + |
|
353 | + if ($perPage) |
|
354 | + { |
|
355 | + return $model->orderBy($sortBy, $sort)->paginate($perPage); |
|
356 | + } |
|
357 | + |
|
358 | + return $model->orderBy($sortBy, $sort)->get(); |
|
359 | + } |
|
360 | + |
|
361 | + /** |
|
362 | + * Save the given data to the logged in user. |
|
363 | + * |
|
364 | + * @param array $credentials |
|
365 | + * @return void |
|
366 | + */ |
|
367 | + public function saveProfile($data) |
|
368 | + { |
|
369 | + if (array_key_exists('profile_picture', $data)) |
|
370 | + { |
|
371 | + $data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures'); |
|
372 | + } |
|
373 | 373 | |
374 | - $data['id'] = \Auth::id(); |
|
375 | - $this->save($data); |
|
376 | - } |
|
377 | - |
|
378 | - /** |
|
379 | - * Ensure access token hasn't expired or revoked. |
|
380 | - * |
|
381 | - * @param string $accessToken |
|
382 | - * @return boolean |
|
383 | - */ |
|
384 | - public function accessTokenExpiredOrRevoked($accessToken) |
|
385 | - { |
|
386 | - |
|
387 | - $accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface'); |
|
388 | - $data = new ValidationData(); |
|
389 | - $data->setCurrentTime(time()); |
|
390 | - |
|
391 | - if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) |
|
392 | - { |
|
393 | - return true; |
|
394 | - } |
|
395 | - |
|
396 | - return false; |
|
397 | - } |
|
374 | + $data['id'] = \Auth::id(); |
|
375 | + $this->save($data); |
|
376 | + } |
|
377 | + |
|
378 | + /** |
|
379 | + * Ensure access token hasn't expired or revoked. |
|
380 | + * |
|
381 | + * @param string $accessToken |
|
382 | + * @return boolean |
|
383 | + */ |
|
384 | + public function accessTokenExpiredOrRevoked($accessToken) |
|
385 | + { |
|
386 | + |
|
387 | + $accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface'); |
|
388 | + $data = new ValidationData(); |
|
389 | + $data->setCurrentTime(time()); |
|
390 | + |
|
391 | + if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) |
|
392 | + { |
|
393 | + return true; |
|
394 | + } |
|
395 | + |
|
396 | + return false; |
|
397 | + } |
|
398 | 398 | } |