Example #1
0
File: auth.php Project: cmsx/auth
 function testLogin()
 {
     $a = new Auth(X::DB());
     $this->assertFalse($a->check(), 'Пользователь не авторизован');
     $this->assertFalse($a->check(BaseAuth\User::ROLE_ADMIN), 'Пользователь не администратор');
     try {
         $a->login('!!!!', 123);
         $this->fail('Недопустимые символы в логине');
     } catch (Exception $e) {
         $this->assertEquals(Auth::ERR_BAD_USERNAME, $e->getCode(), 'Код ошибки 1');
     }
     try {
         $a->login('abc', 'abc');
         $this->fail('Недопустимые символы в пароле');
     } catch (Exception $e) {
         $this->assertEquals(Auth::ERR_BAD_PASSWORD, $e->getCode(), 'Код ошибки 2');
     }
     try {
         $a->login('abc', 666);
         $this->fail('Пользователь не существует');
     } catch (Exception $e) {
         $this->assertEquals(Auth::ERR_WRONG_LOGIN_OR_PASS, $e->getCode(), 'Код ошибки 3');
     }
     $a->login('abc', 123);
     $this->assertTrue($a->check(), 'Пользователь авторизован');
     $this->assertTrue($a->check(BaseAuth\User::ROLE_ADMIN), 'Пользователь - администратор');
     $this->assertEquals('Hello', $a->getUser()->get('name'), 'Пользователь сохранен в объекте Auth');
 }
Example #2
0
function api_login($id, $password)
{
    $auth = new Auth();
    if (!$auth->login($id, $password)) {
        $canon_id = api_get_canonical_id($id);
        if (!$auth->login($canon_id, $password)) {
            return new XMLRPCFault(1, "Authentication failed: {$id}({$canon_id})");
        }
    }
    return false;
}
Example #3
0
 public function action_login()
 {
     $data = array();
     // もし、あなたが送信ボタンを押下したならば、ステップを超えてへ行こう。
     if (Input::post()) {
         $name = Input::post('username');
         $password = Input::post('password');
         //			var_dump($name,$password);
         //			exit;
         //資格を確認。これは前述のテーブルが作成され、
         // 上記のようにテーブルの定義および設定を使用していることが前提となります。
         if (Auth::login()) {
             // 認証情報は OK 、ただちに下記へ
             Response::redirect('pt/update/HTML5');
         } else {
             // おっと!あなたにはあげれません。 再度ログインしてみてください。 username フィールドを再設定し、
             // ビューに戻っていくつかのエラーテキストを与えるためにいくつかの値を設定します。
             $data['username'] = Input::post('username');
             $data['login_error'] = 'メールアドレスかパスワードに誤りがあります';
             print $data['login_error'];
         }
     }
     $this->template->title = 'ログイン画面';
     $this->template->content = View::forge('auth/login');
 }
 function process_login()
 {
     $username = addslashes($_POST["admin_email"]);
     $password = addslashes($_POST["admin_password"]);
     $rememberme = isset($_POST["rememberme"]) ? 1 : 0;
     if ($password == "") {
         $password = "******";
     }
     $row = array("admin_email" => $username, "admin_password" => $password, "rememberme" => $rememberme);
     /*if ($this->ldapLogin($username, $password)) {
     			$row["admin_ldap"] = 1;
     		}*/
     //login pakai row credential
     Auth::login($row);
     //kalau sukses
     if (Auth::isLogged()) {
         //load school setting
         // $ss = new Schoolsetting();
         // $ss->loadToSession();
         //redirect
         //Account::setRedirection ();
         Hook::processHook($this->login_hook);
         Redirect::firstPage();
     } else {
         Redirect::loginFailed();
     }
 }
Example #5
0
 /**
  * Decide whether to update an existing character, or create a new one.
  *
  * @return Response
  */
 public function register()
 {
     $validator = Validator::make($data = Input::only('name', 'password'), Character::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $pheal = new Pheal(Config::get('phealng.keyID'), Config::get('phealng.vCode'));
     $query = $pheal->eveScope->CharacterID(array('names' => $data['name']));
     foreach ($query->characters as $character) {
         $data['characterID'] = $character->characterID;
     }
     if ($data['characterID']) {
         $character = Character::firstOrNew(array('name' => Input::get('name')));
         if (!$character->active) {
             $character->id = $data['characterID'];
             $character->name = $data['name'];
             $character->password = Hash::make($data['password']);
             $character->active = 1;
             if ($character->save()) {
                 Auth::login($character);
                 return Redirect::intended('/');
             }
         } else {
             return Redirect::back()->withErrors(array('name' => 'This character is already registered.'))->withInput();
         }
     } else {
         return Redirect::back()->withErrors(array('name' => 'No character with this name could be found.'))->withInput();
     }
 }
Example #6
0
 function validate()
 {
     if (!Session::has('vatsimauth')) {
         throw new AuthException('Session does not exist');
     }
     $SSO = new SSO(Config::get('vatsim.base'), Config::get('vatsim.key'), Config::get('vatsim.secret'), Config::get('vatsim.method'), Config::get('vatsim.cert'));
     $session = Session::get('vatsimauth');
     if (Input::get('oauth_token') !== $session['key']) {
         throw new AuthException('Returned token does not match');
         return;
     }
     if (!Input::has('oauth_verifier')) {
         throw new AuthException('No verification code provided');
     }
     $user = $SSO->checkLogin($session['key'], $session['secret'], Input::get('oauth_verifier'));
     if ($user) {
         Session::forget('vatsimauth');
         $authUser = User::find($user->user->id);
         if (is_null($authUser)) {
             $authUser = new User();
             $authUser->vatsim_id = $user->user->id;
             $authUser->name = trim($user->user->name_first . ' ' . $user->user->name_last);
         }
         $authUser->last_login = Carbon::now();
         $authUser->save();
         Auth::login($authUser);
         Messages::success('Welcome on board, <strong>' . $authUser->name . '</strong>!');
         return Redirect::intended('/');
     } else {
         $error = $SSO->error();
         throw new AuthException($error['message']);
     }
 }
Example #7
0
 public function postLogin(\Illuminate\Http\Request $request)
 {
     $username = $request->input('username');
     $password = $request->input('password');
     // First try to log in as a local user.
     if (Auth::attempt(array('username' => $username, 'password' => $password))) {
         $this->alert('success', 'You are now logged in.', true);
         return redirect('users/' . Auth::user()->id);
     }
     // Then try with ADLDAP.
     $ldapConfig = \Config::get('adldap');
     if (array_get($ldapConfig, 'domain_controllers', false)) {
         $adldap = new \adldap\adLDAP($ldapConfig);
         if ($adldap->authenticate($username, $password)) {
             // Check that they exist.
             $user = \Ormic\Model\User::where('username', '=', $username)->first();
             if (!$user) {
                 $user = new \Ormic\Model\User();
                 $user->username = $username;
                 $user->save();
             }
             \Auth::login($user);
             //$this->alert('success', 'You are now logged in.', TRUE);
             return redirect('');
             //->with(['You are now logged in.']);
         }
     }
     // If we're still here, authentication has failed.
     return redirect()->back()->withInput($request->only('username'))->withErrors(['Authentication failed.']);
 }
Example #8
0
 /**
  *
  */
 public function login()
 {
     $user = $this->provider->user(Input::get('code'));
     dd($user);
     Auth::login($user);
     return Redirect::home();
 }
 /**
  * Perform authentication before a request is executed.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param $grant
  *
  * @return mixed
  * @throws AccessDeniedException
  */
 public function handle($request, Closure $next, $grant = null)
 {
     $route = $this->router->getCurrentRoute();
     /**
      * FOR (Internal API requests)
      * @note GRANT(user) will always be able to access routes that are protected by: GRANT(client)
      *
      * For OAuth grants from password (i.e. Resource Owner: user)
      * @Auth will only check once, because user exists in auth afterwards
      *
      * For OAuth grants from client_credentials (i.e. Resource Owner: client)
      * @Auth will always check, because user is never exists in auth
      */
     if (!$this->auth->check(false)) {
         $this->auth->authenticate($route->getAuthenticationProviders());
         $provider = $this->auth->getProviderUsed();
         /** @var OAuth2 $provider */
         if ($provider instanceof OAuth2) {
             // check oauth grant type
             if (!is_null($grant) && $provider->getResourceOwnerType() !== $grant) {
                 throw new AccessDeniedException();
             }
         }
         // login user through Auth
         $user = $this->auth->getUser();
         if ($user instanceof User) {
             \Auth::login($user);
             event(new UserLoggedInEvent($user));
         }
     }
     return $next($request);
 }
 public function callback()
 {
     //dd(Input::all());
     if (!$this->fb->generateSessionFromRedirect()) {
         return Redirect::to('/')->with('message', 'Error Facebook Connection!');
     } else {
         $user_fb = $this->fb->getGraph();
         $user = new User();
         $_SESSION['userFbID'] = $user_fb->getProperty('id');
         $name = $user_fb->getProperty('name');
         $id = $_SESSION['userFbID'];
         $email = $user_fb->getProperty('email');
         //$location = $user_fb->getProperty('location');
         $image = 'http://graph.facebook.com/' . $user_fb->getProperty('id') . '/picture?width=300';
         $user->name = $name;
         $user->fbId = $id;
         $user->email = $email;
         $user->image = $image;
         //$user->location = $location;
         $findUsers = User::all();
         $count = 0;
         foreach ($findUsers as $findUser) {
             if ($findUser['fbId'] == $_SESSION['userFbID']) {
                 $count = +1;
             }
         }
         if ($count == 0) {
             $user->save();
         }
         Auth::login($user);
         return Redirect::to('/home');
     }
 }
 public function getStarted()
 {
     if (Auth::check()) {
         return Redirect::to('invoices/create');
     } else {
         if (!Utils::isNinja() && Account::count() > 0) {
             return Redirect::to('/login');
         }
     }
     $user = false;
     $guestKey = Input::get('guest_key');
     if ($guestKey) {
         $user = User::where('password', '=', $guestKey)->first();
         if ($user && $user->registered) {
             return Redirect::to('/');
         }
     }
     if (!$user) {
         $account = $this->accountRepo->create();
         $user = $account->users()->first();
         Session::forget(RECENTLY_VIEWED);
     }
     Auth::login($user, true);
     Event::fire('user.login');
     return Redirect::to('invoices/create');
 }
Example #12
0
 function post_register()
 {
     // set validation rules for new user content.
     $rules = array('name' => 'required|min:3|max:75', 'email' => 'required|unique:users|email', 'password' => 'required|min:5|max:64');
     $v = Validator::make(Input::all(), $rules);
     if ($v->fails()) {
         return Redirect::to('user/new')->with_input('except', array('password'))->with_errors($v);
     }
     $nameArr = explode(' ', Input::get('name'), 2);
     $player = new Player();
     $player->first_name = $nameArr[0];
     $player->last_name = isset($nameArr[1]) ? $nameArr[1] : '';
     $player->save();
     if ($player->save()) {
         $user = new User();
         $user->password = Hash::make(Input::get('password'));
         $user->email = Input::get('email');
         $user->player_id = $player->id;
         if ($user->save()) {
             // log the user in the session
             Auth::login($user->id);
             return Redirect::to('user')->with('welcomeMsg', true);
         } else {
             // oh shit. roll back the player and return an error
             $player->delete();
             return Redirect::to('user/new')->with_input('except', array('password'))->with('error', 'Nah fool... something went real wrong.');
         }
     } else {
         return Redirect::to('user/new')->with_input('except', array('password'))->with('error', 'This user could not be created.');
     }
 }
Example #13
0
 public function post_login()
 {
     $val = Validation::forge();
     $val->add('email', 'Email or Username')->add_rule('required');
     $val->add('password', 'Password')->add_rule('required');
     if ($val->run()) {
         if (!Auth::check()) {
             if (Auth::login(Input::post('email'), Input::post('password'))) {
                 // assign the user id that lasted updated this record
                 foreach (\Auth::verified() as $driver) {
                     if (($id = $driver->get_user_id()) !== false) {
                         $result = [];
                         $result['current_user'] = Model\Auth_User::find($id[1])->username;
                         $result['current_bidder'] = \Config::get('my.yahoo.user_name');
                         $this->response(['status_code' => $this->_status_code['login_success'], 'result' => $result]);
                     }
                 }
             } else {
                 $this->response(['status_code' => $this->_status_code['login_faild']]);
             }
         } else {
             $this->response(['status_code' => $this->_status_code['alredy_logedin']]);
         }
     } else {
         $this->response(['status_code' => $this->_status_code['login_faild']]);
     }
 }
Example #14
0
File: auth.php Project: vano00/jobs
 public function action_index()
 {
     $data = array();
     if (\Input::post()) {
         $username = \Input::post('username');
         $password = \Input::post('password');
         if (\Auth::login($username, $password)) {
             // does the user want to be remembered?
             if (\Input::post('remember_me')) {
                 // create the remember-me cookie
                 \Auth::remember_me();
             } else {
                 // delete the remember-me cookie if present
                 \Auth::dont_remember_me();
             }
             \Response::redirect_back('/');
         } else {
             // Oops, no soup for you. Try to login again. Set some values to
             // repopulate the username field and give some error text back to the view.
             $data['username'] = $username;
             \Session::set_flash('error', 'Wrong username/password combo. Try again');
         }
     }
     // Show the login form.
     $this->template->title = "Login";
     $this->template->content = \View::forge('auth/login.twig', $data);
 }
Example #15
0
 function __construct($model, $action)
 {
     $this->model = $model;
     $this->action = $action;
     if ($action != 'login' && $action != 'logout') {
         $this->user = current_user();
         $this->is_public_route();
         if (!$this->user && !$this->allow_public_access) {
             Response()->not_logged_in();
         }
         if ($this->is_restricted_route()) {
             Response()->not_authorized();
         }
         //Authority::initialize($this->user);
     } else {
         $auth = new Auth();
         if ($action == 'login') {
             $result = $auth->login($_POST['username'], $_POST['password']);
             if ($result !== false) {
                 Response()->successful_login();
             } else {
                 Response()->unsuccessful_login();
             }
         } else {
             $auth->logout();
         }
     }
     //todo:seems like i might be able to have a default handler. If function doesn't exist on this controller, and there is no controller for the specified model, check the actual model for a function with the model name and run it. this may really eliminate the need for controllers. I hope...
 }
 public function addContributor()
 {
     $contributor_first_name = Input::get('contributor-first-name');
     $contributor_last_name = Input::get('contributor-last-name');
     $contributor_mobile = Input::get('contributor-mobile');
     $contributor_obj = NULL;
     if (Auth::guest()) {
         $contributor_obj = User::createContributorAndSave($contributor_first_name, $contributor_last_name, $contributor_mobile);
         Auth::login($contributor_obj, true);
     } else {
         // A user is logged in already. The contributor name and mobile can be same or different
         // ONLY checking by mobile right now. TODO : check if this is OK
         if ($contributor_mobile != Auth::user()->mobile) {
             Log::info("mobile num not equal. MAKE NEW CONTRIB USER !!");
             // Using same contributor twice. Or uses existing user as contributor without knowing that they exist on this platform
             $contributor_obj = User::createContributorIfNotExists($contributor_first_name, $contributor_last_name, $contributor_mobile);
         } else {
             Log::info("mobile num equal. Auth is Contributor !! ");
             $contributor_obj = Auth::user();
             $contributor_obj->makeContributor();
         }
     }
     $au_file = Input::file('au-file');
     $upload_number = Auth::user()->incrementUploadNumber();
     $new_file_name = $contributor_first_name . $contributor_mobile . '_uploaded_by_' . Auth::user()->fname . $upload_number . '.csv';
     $new_file_location = app_path() . '/database/seedAfterReview/';
     $au_file->move($new_file_location, $new_file_name);
     // I will review. No automatic upload
     //$file_full_path = $new_file_location . $new_file_name;
     //Helper::createArmyUpdatesFromFileForContributor($file_full_path, $contributor_obj->id);
     return Redirect::to('dashboard');
 }
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     Event::listen('Aacotroneo\\Saml2\\Events\\Saml2LoginEvent', function (Saml2LoginEvent $event) {
         $user = $event->getSaml2User();
         /*$userData = [
               'id' => $user->getUserId(),
               'attributes' => $user->getAttributes(),
               'assertion' => $user->getRawSamlAssertion()
           ];*/
         $laravelUser = User::where("username", "=", $user->getUserId())->get()->first();
         if ($laravelUser != null) {
             Auth::login($laravelUser);
         } else {
             //if first user then create it and login
             $count = \App\User::all()->count();
             if ($count == 0) {
                 $data = array();
                 $data['lastname'] = "";
                 $data['firstname'] = "";
                 $data['username'] = $user->getUserId();
                 $data['role'] = "admin";
                 $user = \App\User::create($data);
                 \Auth::login($user);
                 return \Redirect::to('/');
             } else {
                 abort(401);
             }
         }
         //if it does not exist create it and go on  or show an error message
     });
 }
 public function post()
 {
     //step 1: validate input-data
     $validate_data = Input::only('contestant_id', 'keystone');
     $validate_rules = array('contestant_id' => 'required|integer', 'keystone' => 'required|min:8');
     $validator = Validator::make($validate_data, $validate_rules);
     if ($validator->fails()) {
         $validate_messages = $validator->messages()->toArray();
         $this->messageController->send($validate_messages, $this::MESSAGE_KEY);
         return Redirect::to('login');
     }
     //step 2: check empty collection from 'contestant_id', bcs it may not exist
     $contestant = Contestant::find(Input::get('contestant_id'));
     if (!$contestant) {
         $this->messageController->send(array('contestant_id' => ['contestant_id:wrong']), $this::MESSAGE_KEY);
         return Redirect::to('login');
     }
     //step 3: compare hashed-value, if equal, allow login
     //what we get after find is a 'collection', not a Contestant's instance, so fetch it, first()
     if (Hash::check(Input::get('keystone'), $contestant->keystone)) {
         Auth::login($contestant);
         if ($contestant->id == 1) {
             //admin after 'login' refer go to 'admin' page
             return Redirect::to('admin');
         } else {
             //contestant after 'login' refer goto 'test' page
             return Redirect::to('test');
         }
     } else {
         $this->messageController->send(array('keystone' => ['keystone:wrong']), $this::MESSAGE_KEY);
     }
     //as a fall-back, return to login
     return Redirect::to('login');
 }
Example #19
0
 public function index()
 {
     if (Session::has('user')) {
         Auth::login(Session::get('user'));
         if (Auth::user()->hak_akses == '1') {
             return Redirect::intended('hrdstaff');
         } elseif (Auth::user()->hak_akses == '2') {
             return Redirect::intended('hrdmanager');
         } elseif (Auth::user()->hak_akses == '3') {
             return Redirect::intended('direktur');
         } elseif (Auth::user()->hak_akses == '4') {
             return Redirect::intended('hrga');
         } elseif (Auth::user()->hak_akses == '5') {
             return Redirect::intended('keuangan');
         } elseif (Auth::user()->hak_akses == '6') {
             return Redirect::intended('karyawan');
         } elseif (Auth::user()->hak_akses == '7') {
             return Redirect::intended('pelamar');
         } else {
             return View::make('home');
         }
     } else {
         return View::make('home');
     }
 }
 /**
  * Creates a new user
  *
  * @return String
  */
 public function store()
 {
     $this->RegistrationForm->validate(Input::all());
     $user = User::create(Input::only('email', 'password'));
     Auth::login($user);
     return Redirect::home();
 }
Example #21
0
 public function Signup()
 {
     if (Input::get('submit')) {
         $email = Input::get('email');
         $username = Input::get('user');
         $password = Input::get('pass');
         if (strlen($email) < 5) {
             return 'Error: email incorrect.';
         }
         if (strlen($username) < 5) {
             return 'Error: username too short. At least 6 characters';
         }
         if (strlen($password) < 5) {
             return 'Error: password too short. At least 6 characters';
         }
         $user = new User();
         $user->email = $email;
         $user->username = $username;
         $user->password = Hash::make($password);
         $user->btc_wallet_password = User::genPassword();
         $user->aur_wallet_password = User::genPassword();
         $user->save();
         Auth::login($user);
         return Redirect::to('/');
     }
 }
 public function create()
 {
     $dc_name = Input::get('dc-name');
     $dc_desc = Input::get('dc-desc');
     $dc_donation_url = Input::get('dc-donation-url');
     $dc_instructions = Input::get('dc-instructions');
     if (Auth::guest()) {
         /////// Create User of type donationcause_adder
         $dcadder_first_name = Input::get('dcadder-first-name');
         $dcadder_last_name = Input::get('dcadder-last-name');
         $dcadder_mobile = Input::get('dcadder-mobile');
         $dcadder_obj = User::createDCAdderAndSave($dcadder_first_name, $dcadder_last_name, $dcadder_mobile);
         // =====[start]================================================
         // Manually logging in user and 'Remember me' = true.
         // So no need to use Auth::attempt
         Auth::login($dcadder_obj, true);
         // =====[end]================================================
     }
     if (Auth::guest()) {
         dd('why is there no Authenticated User here');
     }
     if (!Auth::user()->donationcause_adder) {
         Auth::user()->makeDonationCauseAdder();
     }
     // Storing the image
     $dc_img_file = Input::file('dc-img-file');
     DonationCause::createNewForPosterFromImgFile($dc_name, $dc_desc, $dc_img_file, $dc_donation_url, $dc_instructions, Auth::user()->id);
     return Redirect::route('donate');
 }
 public function fbConnect()
 {
     if (!Auth::check()) {
         $fb_user = Input::get('fb_user');
         $user = User::where('email', '=', $fb_user['email'])->first();
         if ($user != null) {
             if ($user->count()) {
                 Auth::login($user);
                 $user->last_login_at = new DateTime('now');
                 $user->last_ip_address = $_SERVER["REMOTE_ADDR"];
                 $user->save();
                 return Response::json(array('status' => 'logging'));
             } else {
                 //create user account
                 $user = User::create(array('email' => '*****@*****.**', 'username' => 'Monkey', 'password' => Hash::make($this->gen_random_string(12)), 'code' => str_random(60), 'active' => 1));
                 //normally active = 0 but until we can get email validation working it will stay 1);
                 $user->save();
                 Auth::login($user);
                 return Response::json(array('status' => 'registering'));
             }
         } else {
             $fb_user_name = explode(" ", $fb_user['name']);
             //create user account
             $user = User::create(array('email' => $fb_user['email'], 'username' => $fb_user['name'], 'password' => Hash::make($this->gen_random_string(12)), 'first_name' => $fb_user_name[0], 'last_name' => $fb_user_name[1], 'code' => str_random(60), 'active' => 1));
             //normally active = 0 but until we can get email validation working it will stay 1);
             $user->save();
             Auth::login($user);
             return Response::json(array('status' => 'registering'));
         }
     } else {
         return Response::json(array('status' => 'logged'));
     }
 }
 public function postreg()
 {
     //if($slug == Setting::find(3)->value){
     if (Auth::check()) {
         return View::make('admin.index');
     } else {
         $input = Input::all();
         $validator = Validator::make($input, array('username' => 'required|unique:Users,username|between:5,20', 'email' => 'required|email', 'password' => 'required|between:5,50', 'code' => 'required'));
         if ($validator->fails()) {
             $messages = $validator->messages();
             $out = '';
             foreach ($messages->all() as $message) {
                 $out .= $message . '<Br>';
             }
             return View::make('admin.register')->with('error', $out);
         } else {
             if (Input::get('code') !== Setting::find(5)->value) {
                 return View::make('admin.register')->with('error', 'Invalid Code');
             }
             $user = new User();
             $user->email = Input::get('email');
             $user->username = Input::get('username');
             $user->password = Hash::make(Input::get('password'));
             $user->status = 'active';
             $user->save();
             Auth::login($user);
             return Redirect::to('/admin/' . Setting::find(3)->value);
         }
     }
     //}else{
     //App::abort('404');
     //}
 }
Example #25
0
 public function action_login()
 {
     // Already logged in
     Auth::check() and Response::redirect('admin');
     $val = Validation::forge();
     if (Input::method() == 'POST') {
         $val->add('email', 'Email or Username')->add_rule('required');
         $val->add('password', 'Password')->add_rule('required');
         if ($val->run()) {
             if (!Auth::check()) {
                 if (Auth::login(Input::post('email'), Input::post('password'))) {
                     // assign the user id that lasted updated this record
                     foreach (\Auth::verified() as $driver) {
                         if (($id = $driver->get_user_id()) !== false) {
                             // credentials ok, go right in
                             $current_user = Model\Auth_User::find($id[1]);
                             Session::set_flash('success', e('Welcome, ' . $current_user->username));
                             Response::redirect_back('admin');
                         }
                     }
                 } else {
                     $this->template->set_global('login_error', 'Login failed!');
                 }
             } else {
                 $this->template->set_global('login_error', 'Already logged in!');
             }
         }
     }
     $this->template->title = 'ITNT Timesheets Login';
     $this->template->content = View::forge('admin/login', array('val' => $val), false);
 }
 public function postAjaxLogin()
 {
     try {
         if (!isset($_POST)) {
             throw new Exception('Request error');
         }
         $id = \Input::get('id', false);
         $passwd = \Input::get('password', false);
         if (!$id || !$password) {
             throw new Exception('Parameter error');
         }
         $m = \Member::where('uid', '=', md5($id))->where('social', '=', 'rebeauty')->get();
         if ($m == null) {
             throw new Exception('Not founded');
         }
         if (!\Hash::check($passwd, $m->password)) {
             throw new Exception('帳號或密碼錯誤');
         }
         // register user into Auth that is a global variable
         \Auth::login($m);
         return \Redirect::route('frontend.index');
     } catch (Exception $e) {
         return Response::json(array('status' => 'error', 'message' => $e->getMessage(), '_token' => csrf_token()));
     }
 }
 public function register()
 {
     if (Auth::check()) {
         return "You are already logged in. Please wait for the dashboard.";
     } else {
         $input = Input::all();
         $validator = Validator::make($input, array('fname' => "min:4 | max:20 | required", 'email' => 'min:5 | max:100 | required | unique:users,email', 'pass' => 'min:5 | max:30 | required', 'passch' => 'same:pass', 'beta' => 'required | exists:betacodes,code'), array('fname.required' => 'Please enter your name.', 'email.required' => 'Please enter your email.', 'pass.required' => 'Please enter a password.', 'beta.required' => 'Please enter your beta access code.', 'fname.min' => 'Your name must be longer than four letters.', 'fname.max' => 'Your name must be shorter than 20 letters.', 'email.min' => 'Your email must be longer than five letters.', 'email.max' => 'Your email must be shorter than 100 letters.', 'email.unique' => 'That email is already in use. Please use the "Forgot" page for assistance.', 'pass.min' => 'Your password must be longer than five letters.', 'pass.max' => 'Your password must be shorter than 30 letters.', 'passch.same' => 'Your passwords did not match.', 'beta.exists' => 'You entered an invalid beta code.'));
         if ($validator->fails()) {
             $messages = $validator->messages();
             $errors = array();
             foreach ($messages->all() as $message) {
                 array_push($errors, $message);
             }
             return $errors;
         }
         $categories = array(Input::get("fname") . "'s Servers");
         $user = new User();
         $user->fname = Input::get("fname");
         $user->email = Input::get("email");
         $user->password = Hash::make(Input::get('pass'));
         $user->save();
         Auth::login($user);
         $category = new Category();
         $category->uid = Auth::user()->id;
         $category->name = Auth::user()->fname . "s Category";
         $category->order = 999;
         $category->save();
         return "success";
     }
 }
Example #28
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     if (Auth::guest()) {
         \Auth::login(User::first());
     }
     $this->currentUser = \Auth::user();
 }
Example #29
0
 public function testSendingAmessageToAnotherUser()
 {
     $currentUser = Factory::create('App\\User');
     $otherUser = Factory::create('App\\User');
     Auth::login($currentUser);
     $this->visit('/messages/compose/' . $otherUser->id)->submitForm('Submit', ['body' => 'This is the new message to you.'])->verifyInDatabase('messages', ['body' => 'This is the new message to you.'])->verifyInDatabase('message_responses', ['body' => 'This is the new message to you.']);
 }
 /**
  * @param Requests\SignUpRequest $request
  * @param CommandDispatcher $commandDispatcher
  *
  * @return
  */
 public function store(Requests\SignUpRequest $request, CommandDispatcher $commandDispatcher)
 {
     $commandDispatcher->dispatchFrom(RegisterUser::class, $request);
     \Auth::login(User::where('username', $request['username'])->first());
     Flash::overlay('Welcome!!');
     return Redirect::home();
 }