コード例 #1
0
ファイル: AuthController.php プロジェクト: garf/0ez
 public function loginPost(Request $request)
 {
     $redirectTarget = $request->has('target') ? $request->get('target') : 'root-index';
     $email = trim($request->get('email', ''));
     $password = trim($request->get('password', ''));
     $isRemember = $request->has('remember');
     $user = Users::where('email', $email)->first();
     if (empty($user)) {
         Notifications::add('User not registered', 'danger', 'login');
         return Redirect::route('login', ['target' => $redirectTarget])->withInput();
     }
     if (!Hash::check($password, $user->password)) {
         Notifications::add('Wrong password', 'danger', 'login');
         return Redirect::route('login', ['target' => $redirectTarget])->withInput();
     }
     if ($user->active != '1') {
         Notifications::add('User is not allowed to log in', 'danger', 'login');
         return Redirect::route('login', ['target' => $redirectTarget])->withInput();
     }
     try {
         Auth::login($user, $isRemember);
     } catch (QueryException $e) {
         //just for demo purposes
     }
     return Redirect::route($redirectTarget);
 }
コード例 #2
0
ファイル: DashboardController.php プロジェクト: garf/0ez
 public function index()
 {
     view()->share('menu_item_active', 'index');
     Title::prepend('Dashboard');
     $data = ['title' => Title::renderr(' : ', true), 'posts_total' => Posts::count(), 'posts_active' => Posts::where('status', 'active')->count(), 'posts_draft' => Posts::where('status', 'draft')->count(), 'posts_moderation' => Posts::where('status', 'moderation')->count(), 'users_total' => Users::count(), 'users_active' => Users::where('active', '1')->count(), 'users_inactive' => Users::where('active', '0')->count(), 'latest_posts' => Posts::active()->orderBy('published_at', 'desc')->limit(5)->get(), 'popular_posts' => Posts::active()->orderBy('views', 'desc')->limit(5)->get()];
     return view('root.dashboard.index', $data);
 }
コード例 #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if ($request->userID) {
         $user = Users::where("uID", $request->userID)->first();
         if ($request->password) {
             $user->uPassword = md5($request->password);
         }
     } else {
         $user = new Users();
         $user->uPassword = md5($request->password);
         $user->uRegisteredDate = date('Y-m-d');
         $user->uIsActive = 1;
         $user->uRole = 1;
         $user->uUsername = $request->username;
         $user->uEmail = $request->email;
     }
     $user->uBirthday = date('Y-m-d', strtotime($request->birthday));
     $user->uAddress = $request->address;
     $user->uPhone = $request->phone;
     $file = Input::file('image');
     // $file->getRealPath()
     if (!is_null($file)) {
         $destinationPath = public_path() . '/assets/images/avatar/';
         $fileName = explode(".", $file->getClientOriginalName())[0];
         $fileName = $fileName . rand(1, 9999) . "." . $file->getClientOriginalExtension();
         Input::file('image')->move($destinationPath, $fileName);
         Image::make($destinationPath . $fileName)->resize(400, 400)->save($destinationPath . '400x400/' . $fileName);
         $user->uAvatar = $fileName;
     }
     $user->save();
     return Redirect::action('admin\\user@index');
 }
コード例 #4
0
ファイル: getUser.php プロジェクト: PingadoWeb/deliveryApi
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $token = $request->get('token');
     if ($token) {
         $cacheTag = ['users'];
         $cacheKey = $token;
         $data = Cache::tags($cacheTag)->remember($cacheKey, 60 * 48, function () use($request, $token) {
             $_user = Users::where('token', urldecode($token));
             if ($_user->count() > 0) {
                 return $_user->first()->toArray();
             } else {
                 return false;
             }
         });
         if ($data) {
             config(['global.users.current.id' => $data['id']]);
             config(['global.users.current.token' => $token]);
             config(['global.users.current.name' => $data['name']]);
             config(['global.users.current.lastname' => $data['lastname']]);
             config(['global.users.current.email' => $data['email']]);
             config(['global.users.current.active' => $data['active']]);
         } else {
             Cache::tags($cacheTag)->forget($cacheKey);
         }
     }
     return $next($request);
 }
コード例 #5
0
ファイル: AuthController.php プロジェクト: andrey900/slimcms
 public function doLogin($req, $res)
 {
     $allPostPutVars = $req->getParsedBody();
     $auth_type = $this->containerSlim->get('systemOptions')->getValue('email_or_login') or 'email';
     $errors = false;
     if (!$allPostPutVars['password']) {
         $errors = true;
         $this->flash->addMessage('errors', 'The password attribute is required. ');
     }
     if (!$allPostPutVars[$auth_type]) {
         $this->flash->addMessage('errors', 'The login attribute is required. ');
         $errors = true;
     }
     $user = Users::where($auth_type, $allPostPutVars[$auth_type])->get();
     if (!isset($user[0])) {
         $this->flash->addMessage('errors', 'User no find in db.');
         $errors = true;
     } elseif (!$user[0]->active) {
         $this->flash->addMessage('errors', 'User is no active. Please contact administrator system.');
         $errors = true;
     } elseif (!$user[0]->verifyPassword($allPostPutVars['password'])) {
         $this->flash->addMessage('errors', 'User no find in system.');
         $errors = true;
     }
     if ($errors) {
         return $res->withStatus(302)->withHeader('Location', $this->router->pathFor('login'));
     }
     Session::put('auth', true);
     Session::put('user', $user[0]->toArray());
     return $res->withStatus(301)->withHeader('Location', '/admin/dashboard');
 }
コード例 #6
0
ファイル: EdenController.php プロジェクト: kaankilic/eden
 public function __construct()
 {
     $this->beforeFilter(function () {
         $RequestedToken = $this->request->header("X-Authentication");
         $Users = Users::where("BearerToken", "=", $RequestedToken)->first();
         if (is_null($User)) {
             return $this->response->errorUnauthorized();
         }
     });
 }
コード例 #7
0
 /**
  * Store a newly created resource in storage.
  * POST
  * @return Response
  */
 public function store()
 {
     $Users = new Users();
     $Users->first_name = 'Michael';
     $Users->last_name = 'Pierre';
     $Users->age = '31';
     $Users->city = 'Orlando';
     $Users->state = 'Florida';
     $Users->country = 'USA';
     $Users->about = 'Cool Dude';
     $Users->save();
     return Users::where('uid', $Users->id)->get();
 }
コード例 #8
0
 public static function checkImageCommentar($created_by)
 {
     $userCheck = \App\Models\Users::where(['created_by' => '$created_by']);
     if ($userCheck->count() > 0) {
         if (file_exists(public_path() . "/" . $userCheck->first()->image) && !empty($userCheck->first()->image)) {
             return asset($userCheck->first()->image);
         } else {
             return asset("/images/default/no_image.jpg");
         }
     } else {
         return asset("/images/default/no_image.jpg");
     }
 }
コード例 #9
0
 public function checkLogin()
 {
     $request = $this->request();
     $session = $request->getSession();
     $username = $request->get('username');
     $password = $request->get('password');
     if (empty($username) || empty($password)) {
         return json_encode(array('status' => 0, 'msg' => '用户名或密码不能为空'), JSON_UNESCAPED_UNICODE);
     }
     $userinfo = Users::where('username', $username)->first();
     //如果获取不到用户信息,返回提示信息
     if (!$userinfo || $userinfo['password'] != md5($password)) {
         return array('status' => 0, 'msg' => '用户名或者密码错误!');
     }
     $session->set('uid', $userinfo['id']);
     return new RedirectResponse('/admin');
 }
コード例 #10
0
 public function authen($email, $password)
 {
     $validate = new Custom_Validator();
     $arr_msg = $validate->isNull($email);
     if (!$arr_msg["STATUS"]) {
         $arr_msg["INPUT"] = "e-mail";
         echo json_encode($arr_msg);
     }
     $arr_msg = $validate->isNull($password);
     if (!$arr_msg["STATUS"]) {
         $arr_msg["INPUT"] = "password";
         echo json_encode($arr_msg);
     }
     $count = Users::where('user_email', '=', $email)->where('user_password', '=', $password)->where('user_flag', '=', UserFlag::$VERIFY[1])->count();
     if ($count > 0) {
         $user = Users::where('user_email', '=', $email)->where('user_password', '=', $password)->where('user_flag', '=', UserFlag::$VERIFY[1])->get();
         $access_tokens = new Access_tokens();
         $access_tokens->where('email', '=', $email)->delete();
         $token = $this->generateToken($email);
         $access_tokens->email = $email;
         $access_tokens->token = $token;
         $access_tokens->save();
         $arr["email"] = $user[0]["user_email"];
         $arr["name"] = $user[0]["user_name"];
         $arr["lastname"] = $user[0]["user_lastname"];
         $arr["access_token"] = $token;
         $arr["authen"] = "Authentication success.";
         $arr_msg["MESSAGE"] = "Authentication success.";
         $arr_msg["MESSAGE_ARRAY"] = $arr;
         $arr_msg["STATUS"] = true;
         return json_encode($arr_msg);
     } else {
         $arr["authen"] = "Wrong username or password.";
         $arr_msg["MESSAGE"] = "wrong e-mail or password.";
         $arr_msg["MESSAGE_ARRAY"] = $arr;
         $arr_msg["STATUS"] = false;
         return json_encode($arr_msg);
     }
 }
コード例 #11
0
ファイル: AuthController.php プロジェクト: vitos8686/0ez
 public function loginPost()
 {
     $redirectTarget = Input::has('target') ? Input::get('target') : 'root-index';
     $email = trim(Input::get('email', ''));
     $password = trim(Input::get('password', ''));
     $isRemember = Input::has('remember');
     $user = Users::where('email', $email)->first();
     if (empty($user)) {
         Notifications::add('User not registered', 'danger', 'login');
         return Redirect::route('login', ['target' => $redirectTarget])->withInput();
     }
     if (!Hash::check($password, $user->password)) {
         Notifications::add('Wrong password', 'danger', 'login');
         return Redirect::route('login', ['target' => $redirectTarget])->withInput();
     }
     if ($user->active != '1') {
         Notifications::add('User is not allowed to log in', 'danger', 'login');
         return Redirect::route('login', ['target' => $redirectTarget])->withInput();
     }
     Auth::login($user, $isRemember);
     return Redirect::route($redirectTarget);
 }
コード例 #12
0
 public function search(Request $request)
 {
     \Log::info("in search");
     $lastName = $request->input('last_name');
     \Log::info("lastname={$lastName}");
     $users = Users::where('last_name', 'like', $lastName . '%')->orWhere('first_name', $lastName)->get();
     $result = "<option value=''>select User</option>";
     foreach ($users as $user) {
         $result .= "<option value='{$user->id}'>{$user->first_name} {$user->last_name}</option>";
     }
     $data = $this->userData($request);
     $data['selectNames'] = $result;
     $data['title'] = 'Admin';
     $data['description'] = 'Admin';
     return view('management', $data);
 }
コード例 #13
0
ファイル: UserController.php プロジェクト: boodemon/laravel-5
 public function getDelete($id)
 {
     Users::where('id', $id)->delete();
     return redirect()->back();
 }
コード例 #14
0
ファイル: Users.php プロジェクト: eco-nomix/deployed
 public function checkForUserName(Request $request)
 {
     return Users::where('user_name', $request->input('username'))->first();
 }
コード例 #15
0
 public function getGeneration($user, $level)
 {
     \Log::info("id= {$user->id}  level={$level}");
     $field = $this->levelToField($level);
     $users = Users::where($field, $user->id)->get();
     return $users;
 }
コード例 #16
0
ファイル: UsersController.php プロジェクト: Nexor0/test
 /**
  * Проверка ключа подтверждения
  * @param Request $request
  * @return mixed
  */
 public function checkKey(Request $request)
 {
     $phone = $request->input('phone');
     $key = $request->input('user_key');
     $users = Models\Users::where('phone', '=', $phone)->first();
     $v = Validator::make(['user_key' => $key], ['user_key' => 'required|integer|between:0,9999']);
     if ($v->fails()) {
         // Переданные данные не прошли проверку
         return response(array('msg' => 'Неправильный формат кода'))->header('Content-Type', 'application/json');
     }
     if ($users && $users->user_key == $key) {
         Auth::loginUsingId($users->id, true);
         // Аутентификация прошла успешно
         return response(array('redirect' => 'users/profile'))->header('Content-Type', 'application/json');
     }
     return response(array('msg' => 'Проверочный код неверен!'))->header('Content-Type', 'application/json');
 }
コード例 #17
0
ファイル: PostHelpers.php プロジェクト: Abdulhmid/imageup
 private static function findUserPost($createdBy = "")
 {
     return \App\Models\Users::where('username', $createdBy)->first();
 }
コード例 #18
0
 public function fbAuth($request)
 {
     if ($request['username'] && $request['fbToken']) {
         $token = Crypt::encrypt($request['username'] . config('global.ip.current'));
         $_user = Users::where('username', $request['username'])->where('active', 1)->select(['id', 'token', 'name', 'lastname', 'email']);
         if ($_user->count() > 0) {
             $_data = $_user->first();
             if (!empty($_data->token)) {
                 Cache::tags(['managers', 'auth'])->forget($_data->token);
             }
             $data = Users::FBApi('me', [], $request['fbToken']);
             if ($data['id'] === $request['username']) {
                 $_user->update(['token' => $token]);
                 return ['id' => $_data->id, 'name' => $_data->name, 'lastname' => $_data->lastname, 'email' => $_data->email, 'token' => urlencode($token)];
             } else {
                 return new \Exception("Usuário ou token inválido.");
             }
         } else {
             $data = Users::FBApi('me', [], $request['fbToken']);
             if ($data['id'] === $request['username']) {
                 $request['avatar'] = 'http://graph.facebook.com/' . $request['username'] . '/picture';
                 $request['fb_id'] = $request['username'];
                 $_user = $this->store($request);
                 $_user->token = $token;
                 $_user->save();
                 return array_only($_user->toArray(), ['id', 'email', 'name', 'lastname', 'token']);
             } else {
                 return new \Exception("Usuário ou token inválido.");
             }
         }
     } else {
         return new \Exception("Usuário ou token inválido.");
     }
 }