예제 #1
0
 /**
  * Fetch user's avatar.
  * 
  * @param User    $user
  * @param Request $request
  * @return mixed
  * 
  * @author Cali
  */
 public function getAvatar(User $user)
 {
     // Latest avatar
     if ($avatar = $user->localAvatar()) {
         return $this->imageResponse($avatar->src);
     } else {
         return $this->imageResponse(Avatar::DEFAULT_URI, false);
     }
 }
예제 #2
0
 /**
  * Confirm the registration through email.
  *
  * @param Request $request
  * @return mixed
  *
  * @author Cali
  */
 public function confirmRegistration(Request $request)
 {
     $email = Crypt::decrypt($request->input('token'));
     // TODO: Flash message
     User::activateByEmail($email);
     return redirect($this->redirectPath())->with('status', 'success');
 }
예제 #3
0
파일: Avatar.php 프로젝트: projnoah/noah
 /**
  * Move the avatar file into storage.
  *
  * @param UploadedFile $file
  * @param User         $user
  * @return static
  *
  * @author Cali
  */
 public static function move(UploadedFile $file, User $user)
 {
     $path = 'avatars/' . $user->id . '/' . $file->hashName();
     Storage::put($path, file_get_contents($file->getRealPath()));
     $avatar = new static(['type' => 0, 'src' => $path]);
     $user->avatars()->save($avatar);
     return $avatar;
 }
예제 #4
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         return ['status' => 'error', 'messages' => $validator->messages()];
     }
     Auth::login(User::register($request->all()));
     return ['status' => 'succeeded', 'redirect' => $this->redirectPath()];
 }
예제 #5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $email = $this->ask('Enter the email');
     $password = $this->ask('Type in the password to complete, 3 characters minimum');
     $user = User::createAdmin(['username' => $this->argument('username'), 'name' => $this->argument('username'), 'email' => $email, 'password' => bcrypt($password)]);
     if ($user) {
         $this->info('User successfully created, Username: ' . $user->username);
     }
 }
예제 #6
0
파일: Statistic.php 프로젝트: projnoah/noah
 /**
  * Get the total user count.
  *
  * @return int
  * @author Cali
  */
 public static function totalUsers()
 {
     return User::count();
 }
예제 #7
0
 /**
  * Update this user's password.
  *
  * @param User                      $user
  * @param UpdateUserPasswordRequest $request
  * @return array
  *
  * @author Cali
  */
 public function updateUserPassword(User $user, UpdateUserPasswordRequest $request)
 {
     $user->update(['password' => bcrypt(trim($request->input('password')))]);
     return $this->successResponse(['message' => trans('views.admin.pages.settings.updated', ['setting' => trans('views.admin.pages.users.profile.password.heading')])]);
 }
예제 #8
0
 /**
  * Create the admin account and migrate the database.
  *
  * @param $credentials
  * @author Cali
  */
 protected function migrateAndCreateAdmin($credentials)
 {
     env_put('ADMIN_EMAIL', $credentials['email'], true);
     Artisan::call('migrate', ['--force' => 'true']);
     $admin = User::createAdmin($credentials);
     Auth::login($admin, true);
     $this->writeLock();
 }
예제 #9
0
 /**
  * Show the application dashboard.
  * 显示仪表盘
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  *
  * @author Cali
  */
 public function home()
 {
     $blogs = Blog::latest()->get();
     $recommended_users = User::latest()->take(5)->get();
     return view('dashboard.index', compact('blogs', 'recommended_users'));
 }
예제 #10
0
 /**
  * Save the user information along with social account id.
  *
  * @param Request $request
  * @return User
  *
  * @author Cali
  */
 protected function saveUserWithSocialInfo(Request $request)
 {
     // Store social info for future authentication
     $user = User::register($request->all(), collect([$request->input('service') => $request->input('id')])->toJson());
     return $user;
 }
예제 #11
0
 /**
  * Send the response after the user was authenticated.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  bool $throttles
  *
  * @return \Illuminate\Http\Response
  */
 protected function handleUserWasAuthenticated(Request $request, $throttles)
 {
     if ($throttles) {
         $this->clearLoginAttempts($request);
     }
     User::loggedIn();
     // Send back json if request is from ajax
     if ($request->ajax()) {
         return ["status" => "succeeded", "redirect" => $this->redirectPath()];
     }
     if (method_exists($this, 'authenticated')) {
         return $this->authenticated($request, Auth::user());
     }
     return redirect()->intended($this->redirectPath());
 }