本文整理汇总了PHP中Auth::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::validate方法的具体用法?PHP Auth::validate怎么用?PHP Auth::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changepwd
public function changepwd()
{
$error = '';
if (Request::isMethod('post')) {
$oldpwd = trim(Input::get('oldpwd'));
$newpwd = trim(Input::get('newpwd'));
$repwd = trim(Input::get('repwd'));
$project_ids = Input::get('project', array());
if (!$oldpwd || !$newpwd) {
$error = '信息填写不完整';
} else {
if (!Auth::validate(array('username' => Auth::user()->username, 'password' => $oldpwd))) {
$error = '旧密码不正确';
} else {
if ($newpwd != $repwd) {
$error = '2次输入的新密码不一致!';
}
}
}
if (!$error) {
Auth::user()->password = Hash::make($newpwd);
Auth::user()->save();
return Redirect::action('ProjectsController@allProjects');
}
}
return View::make('users/pwd', array('error' => $error));
}
示例2: doLogin
public function doLogin()
{
$rules = array('username' => 'required', 'password' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$userdata = array('username' => Input::get('username'), 'password' => Input::get('password'));
// attempt to do the login
if (Auth::validate($userdata)) {
if (Auth::attempt($userdata)) {
// validation successful!
// redirect them to the secure section or whatever
// return Redirect::to('secure');
// for now we'll just echo success (even though echoing in a controller is bad)
return Redirect::to('admin');
} else {
echo "gagal login";
// validation not successful, send back to form
//return Redirect::to('login');
}
} else {
echo "gagal validasi";
}
} else {
//echo 'gagal validasi';
return Redirect::to('login')->withErrors($validator)->withInput();
}
}
示例3: register
/**
* Register action.
*
* @return $this|\Illuminate\Http\RedirectResponse
*/
public function register()
{
$validator = $this->getRegistrationValidator();
if ($validator->passes()) {
//only allow users to register who actually have a valid ldap account
if ($this->isLdap) {
$creds = $this->getLoginCredentials();
$creds['isRegister'] = true;
if (!Auth::validate($creds)) {
return Redirect::back()->withInput()->withErrors(["password" => [Lang::get('messages.invalid_credentials')]]);
}
}
//if we are using ldap and auto registration, the user will have been created in the Auth::attemp call above
//thus, we need to just load the user using eloquent and not create a new one.
if ($this->isLdap && Config::get('ldap.autoRegister')) {
$user = User::query()->where('username', Input::get('username'))->first();
} else {
$user = $this->userRegistrator->registerUser(Input::except('_token', 'password_confirmation', 'ui_language'), Input::get('ui_language'));
}
if ($user) {
Auth::login($user);
Session::put('ui_language', Input::get('ui_language'));
return Redirect::route("/");
}
return Redirect::back()->withErrors(["password" => [Lang::get('messages.account_creation_failed')]]);
} else {
return Redirect::back()->withInput()->withErrors($validator);
}
}
示例4: postLogin
public function postLogin()
{
$input = Input::all();
$attempt = Auth::attempt(array('email' => $input['email'], 'password' => $input['password'], 'confirmed' => 1));
if ($attempt) {
if (Request::ajax()) {
return Response::json(array('user' => Auth::user()));
} else {
return Redirect::intended('home');
}
} else {
//Attempt again without checking 'confirmed'
$attempt = Auth::validate(array('email' => $input['email'], 'password' => $input['password']));
if ($attempt) {
//Credentials are correct. but email not verified
$error = __('emailNotConfirmedYet');
$emailNotConfirmed = true;
} else {
$error = __('emailOrPasswordIncorrect');
}
if (Request::ajax()) {
return Response::json(array('error' => $error, 'emailNotConfirmed' => !empty($emailNotConfirmed) ? true : false), 400);
} else {
return Redirect::to(route('login'))->with('login:errors', [$error])->withInput();
}
}
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$response = new stdClass();
$statusCode = 201;
$in = Input::only('uuidx', 'email');
$rules = array('uuidx' => 'required | alpha_dash', 'email' => 'required | email | unique:users');
$vd = Validator::make($in, $rules);
if ($vd->fails()) {
$errs = $vd->messages();
if ($errs->has('email')) {
$credentials['email'] = $in['email'];
$credentials['password'] = $in['uuidx'];
if (Auth::validate($credentials)) {
$statusCode = 200;
$response = Auth::user();
} else {
$statusCode = 403;
$response = $errs->all();
}
} else {
$statusCode = 400;
$response = $errs->all();
}
} else {
mt_srand(crc32(microtime()));
$in['uuidx'] = Hash::make($in['uuidx']);
$in['seed'] = mt_rand();
$response = User::create($in);
}
return Response::json($response, $statusCode);
}
示例6: store
public function store()
{
// get inputs from the api
$username = Request::get('username');
$password = Request::get('password');
// determine whether username or email
$identifier = filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
$credentials = array($identifier => $username, 'password' => $password);
// check if creds are valid
if (Auth::validate($credentials)) {
// get the relevant user
$user = \User::where($identifier, '=', $username)->first();
// build the groups array and then loop through the collection to turn it into an array
// unserialising permissions as we go
$user_groups = array();
foreach (\Auth::getUserGroups($user) as $index => $group) {
$group['permissions'] = unserialize($group['permissions']);
array_push($user_groups, $group->toArray());
}
// return user and group info
return Response::json(array('error' => false, 'user' => $user->toArray(), 'groups' => $user_groups), 200);
} else {
// if validation fails, respond
return Response::json(array('error' => true, 'message' => 'user authentication failed'), 401);
}
}
示例7: postLogin
public function postLogin()
{
$input = Input::all();
$rules = array('email' => 'required', 'password' => 'required');
$v = Validator::make($input, $rules);
if ($v->fails()) {
return Redirect::to('login')->withErrors($v);
} else {
$credentials = array('email' => $input['email'], 'password' => $input['password']);
//Check ob Logindaten korrekt
if (Auth::validate($credentials)) {
//Wenn Logindaten korrekt: Check ob Konto aktiviert
$credentials = array('email' => $input['email'], 'password' => $input['password'], 'confirmed' => 1);
if (Auth::validate($credentials)) {
//Falls Logindaten korrekt und Konto aktiviert: User Einloggen
Auth::attempt($credentials);
//Daten aus SAP ziehen
$pispdm = array('ROLLFKT' => 'INST', 'PARTID' => '10000', 'TITLE' => '', 'NAME1' => '', 'NAME2' => '', 'POSTCODE1' => '', 'CITY1' => '', 'CITY2' => '', 'STREET' => '', 'HOUSENUM1' => '', 'TELNUMBER1' => '', 'MOBNUMBER1' => '', 'SMTPADDR' => '', 'ZULNR' => '', 'ZUDATB' => '', 'ZUERNA' => '', 'INSTBART' => '', 'FKTITLE' => '', 'FKNAM' => '', 'FKVNM' => '');
$params = array('PI_ACTVT' => '03', 'PI_ASART' => 'IAB1', 'PI_S_PD_M' => $pispdm);
//$sapresult = App::make('SoapSapController')->callWebserviceRead($params);
//Session::put('sapdata', $sapresult);
return Redirect::to('/');
} else {
//Falls Logindaten korrekt aber Konto nicht aktiviert:
//Redirekt auf Verify Seite mit Option, sich die VerifyMail nochmal schicken zu lassen
$user = User::findByEmailOrFail($input['email']);
$toMail = array('email' => $user->email, 'username' => $user->username, 'confirmation_code' => $user->confirmation_code, 'login' => true);
return View::make('home.verify')->with('toMail', $toMail);
}
} else {
//Falls Logindaten falsch
return Redirect::to('login')->withErrors(['credentials' => 'Benutzername oder Passwort ungültig.']);
}
}
}
示例8: postIndex
public function postIndex()
{
if (Input::has('changepw')) {
$rules = array('oldPass' => 'required', 'newPass1' => 'required|min:8', 'newPass2' => 'required|min:8|same:newPass1');
$input = Input::all();
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return Redirect::to('/account')->withErrors($validator);
}
$user = Auth::user();
if (!Auth::validate(array('name' => $user->name, 'password' => $input['oldPass']))) {
return Redirect::to('/account')->withErrors(array('message' => 'You have entered a wrong password.'));
}
$user->password = Hash::make($input['newPass2']);
$user->save();
return Redirect::to('/account');
} elseif (Input::has('removeacc')) {
$rules = array('remPass' => 'required|min:8');
$input = Input::all();
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return Redirect::to('/account')->withErrors($validator);
}
$user = Auth::user();
if (!Auth::validate(array('name' => $user->name, 'password' => $input['oldPass']))) {
return Redirect::to('/account')->withErrors(array('message' => 'You have entered a wrong password.'));
}
$user->delete();
Auth::logout();
return Redirect::to('/');
}
}
示例9: checkpass
/**
* Validacao: checkpass.
*
* @param $attribute
* @param $value
* @param $parameters
*
* @return int
*/
public function checkpass($attribute, $value, $parameters)
{
if (\Auth::check() != true) {
return false;
}
// Validar
$user = \Auth::user();
$credentials = ['email' => $user->email, 'password' => $value];
return \Auth::validate($credentials);
}
示例10: updateSettings
public function updateSettings()
{
$user = Auth::user();
$validation = Validator::make(Input::all(), array('old_password' => 'required', 'password' => 'required|min:6|confirmed', 'password_confirmation' => 'required|min:6'));
if ($validation->fails()) {
return Redirect::route('settings')->withErrors($validation);
}
$authParams = array('email' => $user->email, 'password' => Input::get('old_password'));
if (Auth::validate($authParams)) {
$user->password = Hash::make(Input::get('password'));
return Redirect::route('settings')->with('success', 'Password is successfully changed');
} else {
return Redirect::route('settings')->with('error', 'Current password is incorrect');
}
}
示例11: postChangePassword
public function postChangePassword()
{
$user = \Auth::User();
$validation = new Validators\SeatUserPasswordValidator();
if ($validation->passes()) {
if (Auth::validate(array('email' => Auth::User()->email, 'password' => Input::get('oldPassword')))) {
$user->password = \Hash::make(Input::get('newPassword_confirmation'));
$user->save();
return Redirect::action('ProfileController@getView')->with('success', 'Your password has successfully been changed.');
} else {
return Redirect::action('ProfileController@getView')->withInput()->withErrors('Your current password did not match.');
}
} else {
return Redirect::action('ProfileController@getView')->withInput()->withErrors($validation->errors);
}
}
示例12: doChangePassword
public function doChangePassword()
{
$password = Input::get('password');
$newpassword = Input::get('newpassword');
$confirm = Input::get('confirm');
$user = Auth::user();
$credentials = ['username' => Auth::user()->username, 'password' => $password];
if (!Auth::validate($credentials)) {
return Redirect::to('profile/edit')->with('error', 'Invalid password')->with('model', $user);
}
if ($newpassword != $confirm) {
return Redirect::to('profile/edit')->with('error', 'Your new password and confirmation are different')->with('model', $user);
}
$user->password = Hash::make($newpassword);
$user->save();
return Redirect::to('profile/edit')->with('model', $user)->with('message', 'Password updated successfully');
}
示例13: testUserLogin
public function testUserLogin()
{
$user = new User();
$user->username = 'admin';
$user->password = Hash::make('admin');
$user->email = 'admin@admin.local';
$this->assertTrue($user->save());
print "\nID do usuário criado :::: {$user->id} : {$user->username} : {$user->password} ::";
// assert the user is not loggedin
$this->assertFalse(Auth::check());
$user_find = User::find($user->id);
$this->assertTrue($user_find->id == 1);
// melhorar
$this->assertTrue(Hash::check('admin', $user_find->password));
$this->assertTrue(Auth::validate(array('username' => $user->username, 'password' => 'admin')));
$this->assertTrue(Auth::attempt());
// if attempt returns true the user is auth
}
示例14: checkLogin
public function checkLogin()
{
$username = \Input::get('username');
$password = \Input::get('password');
$validator = new Validate();
$validated = $validator->validateCreds();
$attempt = \Auth::attempt(array('username' => $username, 'password' => $password));
$menu_items = \MenuItem::all();
$categories = \MenuCategory::all();
if ($validated->passes()) {
if (!\Auth::validate(array('username' => $username, 'password' => $password))) {
return \View::make('accounts.login')->withErrors($validated)->withInput(\Input::only('username'))->with('message', '<p class="alert alert-dismissible alert-danger">Invalid username or password</p>');
}
if ($attempt === true) {
return \View::make('admin.dashboard')->with('menu_items', $menu_items)->with('categories', $categories);
}
}
return \View::make('accounts.login')->withErrors($validated)->withInput(\Input::only('username'));
}
示例15: Login
public function Login()
{
$data = Input::all();
$rules = array('username' => 'required|username', 'password' => 'required|min:6');
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return Redirect::to('/login')->withInput(Input::except('password'))->withErrors($validator);
} else {
$userdata = array('email' => Input::get('email'), 'password' => Input::get('password'));
if (Auth::validate($userdata)) {
if (Auth::attempt($userdata)) {
return Redirect::intended('/');
}
} else {
Session::flash('error', 'Something went wrong');
return Redirect::to('login');
}
}
}