Пример #1
0
 public function __construct()
 {
     VG::checkAuth();
     $user = User::where('id', session()->get('uid'))->first();
     if ($user == null) {
         return;
     }
     $this->uid = $user->id;
 }
Пример #2
0
 public function login(Request $request)
 {
     $email = $request->get('email');
     $password = $request->get('password');
     $u = User::where('email', '=', $email)->first();
     if ($u == null) {
         return response()->json(['error' => 'Wrong login']);
     }
     if ($u->confirmed == 0) {
         return response()->json(['error' => 'Not confirmed']);
     }
     if (!Hash::check($password, $u->password)) {
         return response()->json(['error' => 'Wrong password']);
     }
     $u->access_token = md5(rand()) . md5($u->id . time() . rand() . mt_rand());
     $u->save();
     VG::loginUser($u, $request);
     return response()->json(['access_token' => $u->access_token, 'avatar' => $u->avatar, 'nickname' => $u->nickname, 'user_id' => $u->id, 'sessid' => $request->session()->get('sessid')]);
 }
Пример #3
0
 public function emailConfirmation(Request $request, $token)
 {
     if (($user = User::where('confirmation_token', $token)->first()) != null) {
         if ($user->confirmed == 1) {
             return redirect()->to('/')->with('error', 'Ссылка неверна');
         }
         $user->confirmed = 1;
         $user->save();
         VG::loginUser($user, $request);
         return redirect()->intended('/');
     } else {
         return redirect()->to('/')->with('error', 'Ссылка неверна');
     }
 }
Пример #4
0
 public function __construct()
 {
     VG::checkAuth();
     $user = User::whereId(session()->get('uid'))->first();
     $this->uid = $user->id;
 }