Ejemplo n.º 1
0
 public function facebook()
 {
     $fb = new FacebookModel();
     $fb->setLoginHelper();
     if ($fb->updateUserInformation()) {
         $u = new User($fb->getUserRememberMe());
         $u->login();
         redirect(route('user', ['slug' => $fb->getUserSlug()]));
         return;
     }
     Response::error(401);
 }
Ejemplo n.º 2
0
 public function update()
 {
     $user = User::getData();
     $name = Request::getParam('name');
     $email = Request::getParam('email');
     $newpass = Request::getParam('newpass');
     $tel = Request::getParam('tel');
     $address = Request::getParam('address');
     $mobile = Request::getParam('mobile');
     $gender = Request::getParam('gender');
     $avatar = '';
     if (Request::hasFile('avatar')) {
         $avatar = 'images/' . Request::getFile('avatar')->name;
     }
     if (empty($newpass)) {
         $newpass = Request::getParam('pass');
     }
     if (empty($avatar)) {
         $avatar = $user->avatar;
     }
     if (empty($address)) {
         $address = $user->address;
     }
     $user_columns = ['name' => $name, 'email' => $email, 'pass' => Hash::make($newpass), 'mobile' => $mobile, 'tel' => $tel, 'gender' => $gender, 'address' => $address, 'avatar' => $avatar, 'updated_at' => Carbon::now()];
     if (UserModel::update($user_columns, "id = ?", [User::getData()->id])) {
         goBack();
     } else {
         Response::error(401);
     }
 }
Ejemplo n.º 3
0
 public function run()
 {
     try {
         if (isset($_SERVER['REQUEST_METHOD'])) {
             $request_method = $_SERVER['REQUEST_METHOD'];
             $request_method = Request::isAjax() ? 'AJAX' : $request_method;
             $inputFlag = Request::hasParam('_token');
             // check the request method if PUT, DELETE or POST
             if ($request_method == 'POST') {
                 if (isset($_POST['_method'])) {
                     $request_method = $_POST['_method'];
                 }
             }
             // check if the request method not supported
             if (!in_array($request_method, ['POST', 'GET', 'PUT', 'AJAX', 'DELETE'])) {
                 throw new BadRequestException('Unauthorized: Access is denied, REQUEST_METHOD not found');
             }
             $res = null;
             // if any routes are set with the request method
             if (isset($this->routes[$request_method])) {
                 foreach ($this->routes[$request_method] as $route) {
                     // find the route that matches the requested url
                     if ($route->equals($this->url)) {
                         // if the token field is set check the token
                         if ($route->token) {
                             $tokenFlag = Token::match(Request::getParam('_token'));
                             if (!$inputFlag || $inputFlag && !$tokenFlag) {
                                 throw new TokenMissMatchException('Unauthorized: Access is denied, Token Miss Match!');
                                 die('Token missmatch!');
                             }
                         }
                         // executes the requested route
                         $res = $route->exec();
                         if (is_string($res)) {
                             echo $res;
                         } else {
                             if (!is_null($res)) {
                                 dd($res);
                             }
                         }
                         return;
                     }
                 }
             }
             Response::error(404);
         } else {
             throw new BadRequestException('Unauthorized: Access is denied, REQUEST_METHOD not found');
         }
     } catch (Exception $exc) {
         die($exc->getMessage() . ' please go <a href="' . Request::getPrevUrl() . '">back.</a>');
     }
 }