/** * Update user details * * @param $request * * @return json */ public function userUpdate(Request $request) { $update = User::where('username', $request->user()->username)->update(['email' => $request->email, 'password' => bcrypt($request->password)]); if ($update) { $this->response = ["message" => "Update successful, you will be logged out", "status_code" => 202, "url" => "/logout"]; } else { $this->response = ["message" => "Cannot update", "status_code" => 400]; } return $this->response; }
/** * postEmailForm * * @param Request $request * @return \Illuminate\Http\Response */ public function postEmailForm(Request $request) { $this->validate($request, ['email' => 'required|email']); $response = []; //check if email exist (ajax call) $status = User::whereEmail($request->only('email'))->first(); if ($status == false) { return $response = ["message" => "Invalid", "status_code" => 400]; } else { $response = Password::sendResetLink($request->only('email'), function (Message $message) { $message->subject($this->getEmailSubject()); }); switch ($response) { case Password::RESET_LINK_SENT: return redirect()->back()->with('status', trans($response)); case Password::INVALID_USER: return redirect()->back()->withErrors(['email' => trans($response)]); } } }
/** * Create a default avatar * * @param Request $request * @return \Illuminate\Support\Collection */ protected function createDefaultAvatar(Request $request) { $userID = User::where('username', $request->username)->first(); Avatar::create(['user_id' => $userID->id, 'avatarURL' => $request->avatar]); }
/** * getSocialData Pass the user details to signup form * * @param $userData * @param $provider */ protected function getSocialData($userData, $provider) { $array = ['username' => $userData->getNickname(), 'email' => $userData->getEmail(), 'facebookID' => 0, 'twitterID' => 0, 'githubID' => 0]; $array[$provider . 'ID'] = $userData->getId(); if ($userData->getNickname() === null) { $array['username'] = Str::slug($userData->getName()); } $user = User::create($array); if ($user) { $this->createAvatar($array['username'], $userData->getAvatar()); Auth::loginUsingId($user->id, true); return $this->userHasLoggedIn(); } }
/** * Create test user * * @return \Illuminate\Support\Collection */ public function createUser() { return User::create(['username' => 'testuser', 'email' => '*****@*****.**', 'password' => bcrypt('testpassword'), 'facebookID' => 0, 'twitterID' => 0, 'githubID' => 0]); }