/** * @param array $params * @return \App\DataAccess\Eloquent\User */ public function registerUser(array $params) { $user = $this->user->save($params); $this->mailer->send('emails.register', ['user' => $user], function ($m) use($user) { $m->sender('*****@*****.**', 'Laravel リファレンス')->to($user->email, $user->name)->subject('ユーザー登録が完了しました'); }); }
public function update($id, UserUpdateRequest $request) { $user = $this->userRepository->find($id); if (empty($user)) { abort(404); } $this->userRepository->update($user, $request->all()); return redirect()->action('Admin\\UserController@show', [$id])->with('message-success', \Lang::get('admin.messages.general.update_success')); }
/** * @param \App\Async\Jobs\Job $job * @return bool */ public function execute($job) { $userId = $job->user_id; $user = $this->userRepository->find($userId); if (empty($user)) { return false; } $this->mailService->sendRegisteredMail($user); return true; }
/** * Confirm a users account * * @param string $confirmation_code * @return Response */ public function confirm($confirmation_code) { $user = $this->userRepository->findConfirmUser($confirmation_code); if (!$user) { return redirect()->route('home'); } $this->userRepository->confirm($user); Auth::login($user); return redirect()->route('home'); }
/** * Retrieve a user by the given credentials. * * @param array $credentials * @return \Illuminate\Auth\UserInterface|null */ public function retrieveByCredentials(array $credentials) { $isAccess = $this->acl->getAccessControl($credentials['name']); if ($isAccess) { $user = $this->user->getAuthenticateUser($credentials['id']); if (!$user) { $user = $this->user->addUser($credentials); } if (!is_null($user)) { return new GithubUser((array) $user); } } }
public function renew($email, $token, ResetPasswordRequest $resetPasswordRequest, UserRepositoryInterface $userRepository, TokenRepositoryInterface $tokenRepository) { $input = $resetPasswordRequest->all(); $user = $userRepository->findByEmail($email); if (!$user) { return $this->sendUnauthorized('Email not found.'); } if (!$tokenRepository->exists($user, $token)) { return $this->sendUnauthorized('Invalid token.'); } $user = $userRepository->changePassword($user, $input['password']); $tokenRepository->delete($token); return $this->sendSuccess([], 'Successfully reset your password. Now try logging in.'); }
/** * Store user to the session / Authenticate * * @return Response */ public function store(Request $request, UserRepositoryInterface $userRepository) { $input = $request->only(['email', 'password']); $user = $userRepository->findByEmail($input['email']); if ($user) { if (!$user->confirmed) { return $this->sendUnauthorized('Invalid credentials.'); } } if (!Auth::attempt($input)) { return $this->sendUnauthorized('Invalid credentials.'); } return $this->sendSuccess([], 'Successfully logged in.'); }
/** * * Handles the validation process of an user * * @param User $user * @param $type * @param $code * @return data */ public function validate(User $user, $type, $code) { //Existence $code = $this->confirmationRepository->getByConfirmationCode($code); if ($code == null) { switch ($type) { case 'mail': $this->dataReturn('not-found-mail'); break; case 'phone': $this->dataReturn('not-found-phone'); break; } return $this->data; } //Tests $user_test = $code->user_id == $user->id; $type_test = $code->type == $type; $expiration_test = Carbon::parse($code->created_at)->addHour(2)->isPast(); //Actions if ($expiration_test) { $this->dataReturn('expired'); } else { if ($user_test && $type_test) { $this->userRepository->update($user->id, ["profile" => ["{$type}_confirmed" => true]]); $this->dataReturn('success'); } else { $this->userRepository->update($user->id, ["profile" => ["{$type}_confirmed" => false]]); $this->dataReturn('failed'); } } $this->confirmationRepository->clear($user, $type); return $this->data; }
/** * Register a new user using their Github account. * * @param string $code * * @return \App\User */ public function register($userDetails) { $userDetails->email = $userDetails->getEmail(); $profile = $this->profiles->findByUid($userDetails->getId()); if (is_null($profile)) { $user = $this->users->findByEmail($userDetails->email); if (is_null($user)) { $user = $this->users->createFromGithubData($userDetails); } $profile = $this->profiles->createFromGithubData($userDetails, $user, $userDetails->token); } else { $profile = $this->profiles->updateToken($profile, $userDetails->token); $user = $profile->user; } return $user; }
public function handleWebhook(Request $request) { //TODO FAIRE UN HASH POUR RECRER TOUTE L'OP SANS AUTH $subscription = $this->organization->subscription()->first(); $billing = Billing::where('uuid', $subscription->last_billing_uuid)->get()->first(); if ($request->input('status') == 'success') { $subscription->is_active = true; $subscription->save(); $billing->status = "SUCCESS"; //TODO DEFINIR DES CODES DERREURS ? $billing->is_billed = true; $billing->save(); } else { $billing->status = "ERROR"; $billing->save(); } }
/** * Update the profile of the authenticated user * * @param OrganizationRequest|UserProfileRequest $request * @return Response */ public function update(OrganizationRequest $request) { $this->organization = Organization::findOrFail($this->organization->id); $this->organization->update($request->all()); $this->organization->save(); Flash::success(Lang::get('organization.update-success')); return redirect(action('OrganizationController@edit')); }
/** * Post registration form. * * @return \Illuminate\Http\RedirectResponse */ public function postRegister(Guard $auth) { $form = $this->users->getRegistrationForm(); if (!$form->isValid()) { return $this->redirectBack(['errors' => $form->getErrors()]); } if ($user = $this->users->create($form->getInputData())) { $auth->login($user); return $this->redirectRoute('user.index', [], ['first_use' => true]); } return $this->redirectRoute('home'); }
public function updateUserStatus($user, Request $request) { $this->userRepository->updateUserStatus($user, $request->status); }
/** * Show the user's public profile page. * * @param string $username * * @return \Response */ public function getPublic($username) { $user = $this->users->requireByUsername($username); $tricks = $this->tricks->findAllForUser($user); return view('user.public', compact('user', 'tricks')); }
/** * Show the users index page. * * @return \Response */ public function getIndex() { $users = $this->users->findAllPaginated(); return view('admin.users.list', compact('users')); }
/** * @param UserRequest $request * @param Hasher $hash * @return \Illuminate\View\View */ public function store(UserRequest $request, Hasher $hash) { $this->user->save(['name' => $request->name, 'email' => $request->email, 'password' => $hash->make($request->password)]); return view('user.store'); }
/** * @return array */ public function getUsers() { return $this->user->all(); }
/** * Get the number of followers for the user. * * @param User $user * @return mixed */ public function countFollowers(User $user) { return $this->repository->countFollowers($user); }