Example #1
0
 public function getCallback(Request $request)
 {
     $client = $this->google->getClient();
     $client->authenticate($_GET['code']);
     $token = $client->getAccessToken();
     $request->session()->put('access_token', $token);
     $profile = $this->google->getProfile();
     $user = $this->userRepository->createOrUpdate($profile, $token);
     Auth::login($user);
     return redirect('/')->with('message', 'Successfully logged in with Google.');
 }
Example #2
0
 /**
  * @param Request $request
  * @param Application $app
  * @return RedirectResponse
  */
 public function loginProcessAction(Request $request, Application $app)
 {
     $userRepository = new UserRepository($app['pdo']);
     $user = $userRepository->getByUsername($request->get('username'));
     if (!empty($user)) {
         if (password_verify($request->get('password'), $user->getPassword())) {
             $app['session']->set('logged', true);
             $app['session']->set('user_id', $user->getId());
             return new RedirectResponse('/admin');
         }
     }
     return $app['twig']->render('public/login.html.twig', ['message' => 'Invalid email or password', 'username' => $request->get('username')]);
 }
 /**
  * @param Request|null $request
  *
  * @return \App\Model\User|false
  */
 public function getUser(Request $request = null)
 {
     if (!$request) {
         return;
     }
     $token = base64_decode($request->getHeader('Authorization'));
     if (!$token) {
         return;
     }
     if (!strpos($token, ':')) {
         return;
     }
     list($name, $password) = explode(':', $token);
     return $this->repository->findByNameAndPassword($name, $password);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id, Article $article, User $user)
 {
     return view('admin.articles.edit')->with('article', $article->find($id))->with('user', $user->all());
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id, User $user, Album $album)
 {
     return view('admin.albums.edit')->with('album', $album->find($id))->with('users', $user->all());
 }
Example #6
0
 /**
  * @param int $page
  * @param int $limit
  * @return PaginationInterface
  */
 public function findAll($page, $limit) : PaginationInterface
 {
     return $this->userRepository->findAll($page, $limit);
 }