File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
app/Repositories/Backend/Access/User Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,8 @@ public function create($request)
9696 $ permissions = $ request ->get ('permissions ' );
9797 $ user = $ this ->createUserStub ($ data );
9898
99+ $ this ->checkUserByEmail ($ data , $ user );
100+
99101 DB ::transaction (function () use ($ user , $ data , $ roles , $ permissions ) {
100102 if ($ user ->save ()) {
101103
@@ -323,15 +325,19 @@ public function mark($user, $status)
323325 * @param $user
324326 *
325327 * @throws GeneralException
328+ *
329+ * @return null
326330 */
327- protected function checkUserByEmail ($ input , $ user )
331+ protected function checkUserByEmail ($ input , $ user = null )
328332 {
329333 //Figure out if email is not the same
330- if ($ user ->email != $ input ['email ' ]) {
331- //Check to see if email exists
332- if ($ this ->query ()->where ('email ' , '= ' , $ input ['email ' ])->first ()) {
333- throw new GeneralException (trans ('exceptions.backend.access.users.email_error ' ));
334- }
334+ if ($ user && $ user ->email === $ input ['email ' ]) {
335+ return ;
336+ }
337+
338+ //Check to see if email exists
339+ if ($ this ->query ()->where ('email ' , '= ' , $ input ['email ' ])->withTrashed ()->exists ()) {
340+ throw new GeneralException (trans ('exceptions.backend.access.users.email_error ' ));
335341 }
336342 }
337343
You can’t perform that action at this time.
0 commit comments