Esempio n. 1
0
 /**
  * Override login method
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
  */
 public function login(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     // If the class is using the ThrottlesLogins trait, we can automatically throttle
     // the login attempts for this application. We'll key this by the username and
     // the IP address of the client making these requests into this application.
     $throttles = $this->isUsingThrottlesLoginsTrait();
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $credentials = $this->getCredentials($request);
     if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
         //Find same user in db, kill the previous session and save current session id
         $user = User::where('email', $request->get('email'))->first();
         if (!is_null($user->session_id)) {
             Session::getHandler()->destroy($user->session_id);
         }
         $user->session_id = Session::getId();
         $user->save();
         return $this->handleUserWasAuthenticated($request, $throttles);
     }
     // If the login attempt was unsuccessful we will increment the number of attempts
     // to login and redirect the user back to the login form. Of course, when this
     // user surpasses their maximum number of attempts they will get locked out.
     if ($throttles) {
         $this->incrementLoginAttempts($request);
     }
     return $this->sendFailedLoginResponse($request);
 }
Esempio n. 2
0
 protected function authenticated(Request $request, User $user)
 {
     $previousSessionID = $user->session;
     if (!$previousSessionID) {
         Session::getHandler()->destroy($previousSessionID);
     }
     $this->guard()->user()->session = Session::getId();
     $this->guard()->user()->save();
     return redirect()->intended($this->redirectPath());
 }
 /**
  * Execute creating a new batch.
  *
  * @return bool|Batch
  */
 public function handle()
 {
     $batch = new Batch();
     $batch->locked = false;
     $batch->session_id = Session::getId();
     $batch->uuid = uuid();
     $batch->lifetime = $this->lifetime;
     $batch->description = $this->description;
     $batch->name = $this->name;
     if ($batch->save()) {
         return $batch;
     }
     return false;
 }
Esempio n. 4
0
 /**
  * @return User|array|null
  */
 public function getUserBySessionToken()
 {
     if (Auth::check()) {
         $header = apache_request_headers();
         $session_token_from_parse = $header['X-Parse-Session-Token'];
         $laravel_session_id = Session::getId();
         if ($laravel_session_id == $session_token_from_parse) {
             $result_array = Auth::user();
             $result_array['sessionToken'] = Session::getId();
             return $result_array;
         } else {
             $this->logout();
             return ParseHelperClass::error_message_return(209, ", user are logged out");
         }
     }
     return ParseHelperClass::error_message_return(209);
 }
Esempio n. 5
0
 /**
  * Log the user out of the application.
  *
  * @return void
  */
 public function logout()
 {
     $user = $this->user();
     // If we have an event dispatcher instance, we can fire off the logout event
     // so any further processing can be done. This allows the developer to be
     // listening for anytime a user signs out of this application manually.
     $this->clearUserDataFromStorage();
     MemberToken::where(['sessionId' => Session::getId()])->delete();
     if (isset($this->events)) {
         $this->events->fire('auth.logout', [$user]);
     }
     // Once we have fired the logout event we will clear the users out of memory
     // so they are no longer available as the user is no longer considered as
     // being signed into this application and should not be available here.
     $this->user = null;
     $this->loggedOut = true;
 }
 public function ResetPassworduser(Request $request)
 {
     $netasset = DB::table('TBL_USER')->Where('EMP_ID', '=', get_userID())->first();
     $agent = new MeaAgent();
     $data = array("session_id" => Session::getId(), "username" => $netasset->USERNAME, "old_password" => $request->input('old_password'), "new_password" => $request->input('new_password'));
     //        var_dump($data);
     $curl = new Curl('CHANGE_PASS', $data);
     $result_login = $curl->getResult();
     if ($result_login->errCode != 0) {
         // login fail
         return redirect()->to('editprofile')->withErrors(['ไม่พบชื่อ login นี้', 'The email or password you entered is incorrect.']);
     } else {
         // logged in
         //            session(['logged_in' => true, 'user_data' => $result_login->result[0], 'access_channel' => 'frontend']);
         Logprocess(7, $data);
         return redirect()->to('editprofile')->with('message', 'ท่านได้เปลี่ยนรหัสผ่านเรียบร้อยแล้ว');
     }
 }
 public function update(Request $request, $id)
 {
     $session_id = Session::getId();
     if (!$session_id) {
         return response('', 400);
     }
     $this->validate($request, ['id' => 'required|integer']);
     $bookmark = Bookmark::find($id);
     if ($request->bookmark) {
         $bookmark->bookmark = $request->bookmark;
         $bookmark->save();
     }
     if ($request->bookmarked_at) {
         $bookmarked_at = new Carbon($request->bookmarked_at, auth()->user()->timezone);
         $bookmarked_at->setTimezone('UTC');
         $bookmark->bookmarked_at = $bookmarked_at->toDateTimeString();
         $bookmark->save();
     }
     return response('', 204);
 }
Esempio n. 8
0
 public function checkLogin(Request $request)
 {
     $agent = new MeaAgent();
     $data = array("session_id" => Session::getId(), "username" => $request->input('username'), "pwd" => $request->input('password'), "os" => $agent->platform(), "browser" => $agent->browser(), "ip_address" => $request->ip(), "access_channel" => $agent->access_channel(), "device_id" => "", "device_os" => $agent->platform());
     $curl = new Curl('Login', $data);
     $result_login = $curl->getResult();
     $retError = "";
     if ($result_login->errCode != 0) {
         switch ($result_login->errCode) {
             case 1:
                 $retError = "ท่านระบุรหัสผู้ใช้งานไม่ถูกต้อง";
                 break;
             case 2:
                 $retError = "ท่านระบุรหัสผ่านไม่ถูกต้อง";
                 break;
             case 7706:
                 $retError = "รหัสผู้ใช้งานของท่านไม่ได้รับอนุญาตให้เข้าใช้งานระบบ กรุณาติดต่อผู้ดูแลระบบ";
                 break;
             case 7707:
                 $retError = "ท่านไม่สามารถเข้าใช้งานระบบได้ เนื่องจากท่านได้ลาออกจากสมาชิกกองทุน เมื่อวันที่ " . get_date_notime($result_login->leave_fund_group_date) . " หากต้องการรายละเอียดเพิ่มเติม กรุณาติดต่อกองทุนสำรองเลี้ยงชีพ";
                 break;
             default:
                 $retError = 'The email or password you entered is incorrect.';
                 break;
         }
         // login fail
         return redirect()->to('login')->withErrors([$retError]);
     } else {
         if ($result_login->result[0]->first_login_flag == "0") {
             //echo "asdasd" . $result_login->result[0]->first_login_flag;
             //                session(['first_emp_id' => $filter1]);
             return redirect()->to('firstlogin')->with('emp_id', $result_login->result[0]->emp_id);
         } else {
             // logged in
             session(['logged_in' => true, 'user_data' => $result_login->result[0], 'access_channel' => 'frontend']);
             // echo  "hello";
             return redirect()->intended('/profile');
         }
     }
 }
Esempio n. 9
0
 /**
  * Updates the session of the current user.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeUpdateCurrent(Builder $query)
 {
     $user = Sentinel::check();
     return $query->where('id', Session::getId())->update(['user_id' => $user ? $user->id : null]);
 }
Esempio n. 10
0
 public function session_id()
 {
     return Session::getId();
 }
Esempio n. 11
0
 public function ReqPassword(Request $request)
 {
     $data = array("session_id" => Session::getId(), "username" => $request->input('username'));
     $curl = new Curl('REQUEST_NEW_PASS', $data);
     $result_login = $curl->getResult();
     //        var_dump($result_login);
     $staturet = false;
     $message = "";
     if ($result_login->errCode != 0) {
         $message = "ไม่พบผู้ใช้นี้";
     } else {
         $message = "ระบบได้ส่ง password ใหม่ไปทางอีเมล์ ของผู้ใช้นี้เรียบร้อยแล้ว";
         $staturet = true;
     }
     return response()->json(array('success' => $staturet, 'html' => $message));
 }
Esempio n. 12
0
 /**
  * Updates the session of the current user.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeLogoutCurrent(Builder $query)
 {
     return $query->where('id', SessionFacade::getId())->update(['user_id' => null]);
 }
 public function __construct()
 {
     $this->sessionId = Session::getId();
     $this->adminUser = Auth::admin()->get();
 }
 /**
  * Create a new session.
  *
  * @param string $ownerType Session owner's type (user, client)
  * @param string $ownerId Session owner's ID
  * @param string $clientId Client ID
  * @param string $clientRedirectUri Client redirect URI (default = null)
  *
  * @return int The session's ID
  */
 public function create($ownerType, $ownerId, $clientId, $clientRedirectUri = null)
 {
     return $this->getConnection()->table('oauth_sessions')->insertGetId(['client_id' => $clientId, 'owner_type' => $ownerType, 'owner_id' => $ownerId, 'session_key' => Session::getId(), 'client_redirect_uri' => $clientRedirectUri, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
 }
Esempio n. 15
0
 /**
  * Determine the unique prefix for the key by name.
  *
  * @param $name
  *
  * @return string
  * @throws \Seat\Services\Exceptions\SettingException
  */
 public static function get_key_prefix($name)
 {
     // Ensure we have a prefix to work with.
     if (is_null(static::$prefix)) {
         throw new SettingException('No prefix defined. Have you extended and declared $prefix?');
     }
     return implode('.', [Session::getId(), static::$prefix, $name]);
 }
Esempio n. 16
0
 /**
  * This action can be used to send generic user actions.
  * @param  string $itemid          An item ID to identify an item on your website. Eg: "POST42"
  * @param  string $itemdescription An item description that is displayed when showing recommendations on your website.
  * @param  string $itemurl         An item URL that links to the item page. Please give an absolute path.
  * @param  string $actiontype      A required action type you want to use to send.
  * @param  string $actionvalue     If your action type uses action values this parameter is required.
  * @param  string $userid          A user ID.
  * @param  string $itemimageurl    An optional item image URL that links to an imagine of the item. Please give an absolute path.
  * @param  string $actiontime      An action time parameter that overwrites the current timestamp of the action. The parameter has the format "dd_MM_yyyy_HH_mm_ss".
  * @param  string $itemtype        An item type that denotes the type of the item (`IMAGE`, `BOOK` etc.). If not supplied, the default value `ITEM` will be used.
  * @param  string $sessionid       A session ID of a user.
  * @return array The decoded JSON response
  */
 public function sendAction($itemid, $itemdescription, $itemurl, $actiontype, $actionvalue = null, $userid = null, $itemimageurl = null, $actiontime = null, $itemtype = null, $sessionid = null)
 {
     if (is_null($sessionid)) {
         $sessionid = Session::getId();
     }
     foreach (['itemid', 'itemdescription', 'itemurl', 'actiontype', 'actionvalue', 'userid', 'itemimageurl', 'actiontime', 'itemtype', 'sessionid'] as $param) {
         $this->setQueryParam($param, ${$param});
     }
     // Set the endpoint name and send the request
     $this->setEndpoint('sendaction');
     return $this->sendRequest();
 }
Esempio n. 17
0
 public function session()
 {
     return response(Session::getId(), 200);
 }
Esempio n. 18
0
 public function setBookmark(Request $request)
 {
     $session_id = Session::getId();
     if (!$session_id) {
         return response('', 400);
     }
     $this->validate($request, ['lesson_id' => 'required|integer', 'bookmark' => 'required|string']);
     $bookmark = new Bookmark();
     $bookmark->lesson_id = $request->lesson_id;
     $bookmark->bookmark = $request->bookmark;
     $bookmark->save();
     return response('', 201);
 }