private function findUser($credentials)
 {
     $user = $this->user->findByCredentials((array) $credentials);
     if ($user) {
         return $user;
     }
     throw new UserNotFoundException();
 }
 public function findUser()
 {
     $user = $this->user->find($this->input->userId);
     if ($user) {
         return $user;
     }
     throw new UserNotFoundException();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function store(MediaImageRequest $request, $id)
 {
     if ($this->auth->user()->hasRole('admin')) {
         $user = $this->user->find($id);
     } else {
         $user = $this->auth->user();
     }
     $user->clearMediaCollection('profile');
     $savedImage = $user->addMedia($request->files->get('image'))->toMediaLibrary('profile');
     return $this->response->item($savedImage, new ProfilePictureTransformer());
 }
Exemple #4
0
 public function getRanking($iso = false)
 {
     $this->user->pushCriteria(new OrderBy('points'));
     if (!$iso) {
         $users = $this->user->all()->take(32);
         $title = trans('user::ui.ranking.global');
     } else {
         $country = $this->country->findByField('iso2', $iso)->first();
         $users = $this->user->findWhere(['country_id' => $country->id]);
         $title = trans('user::ui.ranking.country', ['country' => $country->short_name]);
     }
     return theme('user.learning.ranking', compact('users', 'title'));
 }
Exemple #5
0
 public function sendResetPassword($user, Authentication $auth)
 {
     $user = $this->user->find($user);
     $code = $auth->createReminderCode($user);
     event(new UserHasBegunResetProcess($user, $code));
     flash(trans('user::auth.reset password email was sent'));
     return redirect()->route('admin.user.user.edit', $user->id);
 }
 /**
  *
  */
 private function emptyUserTables()
 {
     foreach ($this->user->all() as $user) {
         $this->user->delete($user->id);
     }
     foreach ($this->role->all() as $role) {
         $this->role->delete($role->id);
     }
 }
 /**
  * Update the password of the given user.
  *
  * @param UpdateProfilePasswordRequest|UpdateUserRequest $request
  *
  * @return Response
  *
  * @internal param int $id
  */
 public function updatePassword(UpdateProfilePasswordRequest $request)
 {
     $user = $this->user->find($this->auth->id());
     $credentials = ['id' => $this->auth->id(), 'email' => $user->email, 'password' => $request->old_password];
     if (!$this->auth->attempt($credentials)) {
         Flash::error(trans('user::messages.invalid old password'));
         return redirect()->back();
     }
     $this->user->update($request->all(), $this->auth->id());
     flash(trans('user::messages.password updated'));
     return redirect()->back();
 }
Exemple #8
0
 public function compose($view)
 {
     $this->user->pushCriteria(new UserOrderCriteria());
     $view->users = $this->user->all();
 }
Exemple #9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int      $id
  * @return Response
  */
 public function destroy($id)
 {
     $this->user->delete($id);
     flash(trans('user::messages.user deleted'));
     return redirect()->route('admin.user.user.index');
 }
Exemple #10
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $this->user->delete($id);
     flash(trans('core::messages.resource.resource deleted', ['name' => trans('user::users.title.user')]));
     return redirect()->route('backend::user.user.index');
 }
 public function run()
 {
     Model::unguard();
     $role = $this->role->findByName('Admin');
     $this->user->createWithRoles(['email' => '*****@*****.**', 'password' => 'demo', 'first_name' => 'John', 'last_name' => 'Doe'], [$role->id], true);
 }
Exemple #12
0
 /**
  * Display a listing of the resource
  * @return Response
  */
 public function index()
 {
     $users = $this->user->all();
     $currentUser = $this->auth->check();
     return view('user::admin.users.index', compact($users, $currentUser));
 }
Exemple #13
0
 public function update(UpdateProfileRequest $request)
 {
     $this->user->update($this->auth->check(), $request->all());
     return redirect()->route('user.account')->with('success', 'Profile updated');
 }
Exemple #14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $this->user->delete($id);
     return $this->successDeleted();
 }
 /**
  * Assign a role to the given user.
  * @param  \Modules\User\Repositories\UserRepository $user
  * @param  \Modules\User\Repositories\RoleRepository $role
  * @return mixed
  */
 public function assignRole($user, $role)
 {
     return $user->assignRole($role);
 }
Exemple #16
0
 protected function createUser(array $data)
 {
     return $this->user->create(['username' => $data['username'], 'email' => $data['email'], 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'country_id' => $data['country_id'], 'password' => bcrypt($data['password'])]);
 }