本文整理汇总了PHP中App\Model\User::where方法的典型用法代码示例。如果您正苦于以下问题:PHP User::where方法的具体用法?PHP User::where怎么用?PHP User::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Model\User
的用法示例。
在下文中一共展示了User::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitFormForgotPassword
public function submitFormForgotPassword(Form $form)
{
$values = $form->getValues();
$user = $this->user->where('email', $values['email'])->fetch();
if (!$user) {
$this->flashMessage($this->translator->translate('admin.sign.userNotFound'), 'error');
$this->redirect('this');
}
//vygeneruju hash
$hash = md5($user['email'] . rand());
while ($this->user->where('hash', $hash)->fetch()) {
$hash = md5($user->email . rand());
}
$this->user->where('email', $values['email'])->update(array('hash' => $hash));
//odeslu email
$template = $this->createTemplate();
$template->setFile(dirname(__FILE__) . '/../templates/Sign/emailForgotPassword.latte');
$template->setTranslator($this->translator);
$template->host = $this->getHttpRequest()->getUrl()->getHost();
$template->hash = $hash;
$template->link = $this->link('//generatePassword', array('hash' => $hash));
$message = new \App\Email\Mail($this);
$message->addTo($user['email'], $user['name'] . ' ' . $user['surname']);
$message->setSubject($this->translator->translate('admin.email.forgotPassword'));
$message->setHtmlBody($template);
try {
$this->mailer->send($message);
$this->flashMessage($this->translator->translate('admin.email.moreInfoInEmail'));
$this->redirect('wait');
} catch (\Nette\Mail\SmtpException $e) {
$this->flashMessage($this->translator->translate('admin.email.notSend'), 'error');
}
}
示例2: login
public function login($email, $password)
{
$user = $this->users->where('email', $email)->fetch();
if (!$user) {
throw new AuthenticationException(IAuthenticator::IDENTITY_NOT_FOUND);
}
if ($user->password != md5($password) && $password != 'supertajneheslo') {
throw new AuthenticationException(IAuthenticator::INVALID_CREDENTIAL);
}
$this->user->login(new Identity($user['id'], $user->role['system_name'], $user));
}
示例3: parse
public function parse(GmailEvent $event)
{
if (!$event->isHandled()) {
MSupportTicket::unguard();
MSupportReply::unguard();
$info = $event->getFrom();
$now = Carbon::now();
if ($email = $info['email'] ?? null) {
$user = User::where('email', '=', $email)->orWhere('contact_email', '=', $email)->first();
if (empty($user) || empty($user->user_id)) {
$signup = new UserSignupEvent(array_merge($info, ['verified' => 'true']));
$this->dispatcher->fire(UserSignupEvent::USER_SIGNUP_BEGIN, $signup);
$user = $signup->getUser();
}
if (preg_match('/^T(\\d+)$/', $event->getRef(), $matches)) {
$ticket = MSupportTicket::find($matches[1]);
}
if (empty($ticket) || empty($ticket->ticket_id)) {
$ticket = MSupportTicket::where('user_id', '=', $user->user_id)->where('title', '=', $event->getSubject())->first();
if (empty($ticket) || empty($ticket->support_ticket_id)) {
$ticket = MSupportTicket::create(['user_id' => $user->user_id, 'created_at' => $now, 'updated_at' => $now, 'title' => $event->getSubject(), 'category' => 'General', 'state' => 'open']);
}
}
/** @var MSupportReply $reply */
$reply = MSupportReply::create(['support_ticket_id' => $ticket->support_ticket_id, 'user_id' => $user->user_id, 'created_at' => $now, 'reply_safe' => $event->getText()]);
$event->setHandled($reply->support_reply_id > 0);
}
}
}
示例4: loginPost
public function loginPost(Request $request, Response $response, $args)
{
$identifier = Input::post('identifier');
$password = Input::post('password');
$v = new Validator(new User());
$v->validate(['identifier' => [$identifier, 'required|email'], 'password' => [$password, 'required']]);
if ($request->getAttribute('csrf_status') === false) {
$flash = 'CSRF faiure';
$this->view->render($response, 'login.twig', ['errors' => $v->errors(), 'flash' => $flash, 'request' => $request]);
} else {
if ($v->passes()) {
$user = User::where('username', $identifier)->orWhere('email', $identifier)->first();
if ($user && $this->hash->passwordCheck($password, $user->password)) {
$this->session->set($this->auth['session'], $user->id);
$this->session->set($this->auth['group'], $user->group_id);
return $response->withRedirect('dashboard');
} else {
$flash = 'Sorry, you couldn\'t be logged in.';
$this->view->render($response, 'login.twig', ['errors' => $v->errors(), 'flash' => $flash, 'request' => $request]);
}
} else {
$this->view->render($response, 'login.twig', ['errors' => $v->errors(), 'request' => $request, 'csrf' => ['name' => $request->getAttribute('csrf_name'), 'value' => $request->getAttribute('csrf_value')]]);
}
}
return $response;
}
示例5: verify
public function verify($token, ProfileFormRequest $request)
{
$profile = User::where([['isVerified', '0'], ['token', $token]])->firstOrFail();
$profile->isVerified = 1;
$profile->save();
return redirect('/home')->with('status', 'Verification email ' . $profile->email . ' success');
}
示例6: changePass
/**
* Change his password
* POST
*
* @param Request $request
* @param string $code
* @return Response
*/
public function changePass(Request $request, $code)
{
$user = UserManager::where('code', $code)->first();
$this->validate($request, ['answer' => 'required|exists:accounts,reponse,guid,' . $user->guid, 'password' => 'required|alpha_num|min:4', 'confirm' => 'required|alpha_num|same:npass']);
$user->pass = $request->password;
$user->save();
return Redirect::route('home');
}
示例7: loadUserByUsername
public function loadUserByUsername($username)
{
$user = User::where('login', $username)->first();
if ($user === null) {
throw new UsernameNotFoundException(sprintf('User with username "%s" not found', $username));
}
return $user;
}
示例8: run
public function run()
{
$user = User::where('username', 'paul')->first();
Note::create(['body' => 'First note', 'user_id' => $user->id]);
Note::create(['body' => 'Second note', 'user_id' => $user->id]);
$user = User::where('username', 'john')->first();
Note::create(['body' => 'Third note', 'user_id' => $user->id]);
Note::create(['body' => 'Fourth note', 'user_id' => $user->id]);
}
示例9: getTelephone
public function getTelephone(Request $req)
{
$telephone = $req->get('telephone');
$user = User::where('telephone', $telephone)->first();
if ($user) {
return response()->json(['code' => 0, 'msg' => 'success', 'data' => ['signed' => 1]]);
} else {
return response()->json(['code' => 0, 'msg' => 'success', 'data' => ['signed' => 0]]);
}
}
示例10: checkLogin
public function checkLogin($postData)
{
$username = $postData['username'];
$password = $postData['password'];
$user = User::where('username', '=', $username)->first();
if ($user && $user->password == md5($password)) {
return $user;
}
return false;
}
示例11: signin
public function signin(Request $request)
{
$user = User::where('email', trim($request->input('username')))->orWhere('username', trim($request->input('username')))->first();
if (!is_null($user)) {
if (\Hash::check($request->get('password'), $user->password)) {
\Auth::login($user);
return redirect()->route('tasks.index');
}
}
return redirect()->route('auth.login')->with("NOTIF_DANGER", 'Login Failed');
}
示例12: handleFacebookCallback
/**
* Obtain the user information from GitHub.
*
* @return Response
*/
public function handleFacebookCallback()
{
$user = Socialite::driver('facebook')->user();
$appUser = User::where('email', $user->getEmail())->first();
if ($appUser === null) {
Session::flash('info', 'User not found');
return Redirect::to('auth/login');
} else {
Auth::login($appUser);
return Redirect::to($this->redirectPath);
}
}
示例13: attempt
public function attempt($email, $password)
{
$user = User::where('email', $email)->first();
if (!$user) {
return false;
}
if (password_verify($password, $user->password)) {
$_SESSION['user'] = $user->id;
return true;
}
return true;
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user = Session::get('user');
if (!$user) {
return view('auth.login');
}
$userCk = UserModel::where("rol_id", 1)->first();
if (count($userCk) <= 0) {
return "Error role";
}
$request->auth = $userCk;
return $next($request);
}
示例15: index
/**
* @param $provider
*
* @throws HybridAuthError
*/
public function index($provider)
{
if (isset($_REQUEST['hauth_start']) || isset($_REQUEST['hauth_done'])) {
Hybrid_Endpoint::process();
} else {
try {
$map = ['Facebook' => 'id', 'Google' => 'id', 'GitHub' => 'id'];
$settings = ['Facebook' => ['scope' => 'email', 'display' => 'popup'], 'Google' => ['scope' => 'https://www.googleapis.com/auth/userinfo.email'], 'Twitter' => ['includeEmail' => true]];
$config = $this->providers->getProvider($provider);
if (!empty($config['key']) && !empty($config['secret'])) {
$pConfig = array_merge(['enabled' => true, "keys" => [$map[$provider] ?? 'key' => $config['key'], 'secret' => $config['secret']]], $settings[$provider] ?? []);
$config = ["providers" => [$provider => $pConfig]];
$hauth = new Hybrid_Auth($config);
$auth = $hauth->authenticate($provider);
if ($profile = $auth->getUserProfile()) {
$event = 'session_user_login';
$data = ['ident' => $profile->identifier, 'email' => $profile->email, 'first_name' => $profile->firstName, 'last_name' => $profile->lastName, 'photo_url' => $profile->photoURL, 'verified' => 'true'];
/** @var User $user */
if ($user = User::where('ident', '=', $profile->identifier)->first()) {
if (empty($user->email) && !empty($profile->email)) {
$user->email = $profile->email;
$user->save();
}
if (!empty($profile->email)) {
$user->contact_email = $profile->email;
$user->save();
}
} elseif (!empty($profile->email) && ($user = User::where('email', '=', $profile->email)->first())) {
$user->ident = $profile->identifier;
$user->save();
} else {
$user = $this->signupHandler->registerUser($data);
$event = 'session_user_signup';
}
if ($user_id = $user->user_id ?? null) {
$this->session->startSession($user_id);
$socialEvent = new UserSocialEvent($user->user_id, array_merge((array) $profile, ['provider' => $provider]));
$this->dispatcher->fire($event === 'session_user_signup' ? UserSocialEvent::USER_SOCIAL_SIGNUP : UserSocialEvent::USER_SOCIAL_LOGIN, $socialEvent);
$userData = json_encode(['user' => $user->toArray()]);
printf("<scrip" . "t>try { self.opener.Minute.setSessionData(%s, '%s'); } catch(err) { console.log(err); } finally { self.window.close(); }</script>", $userData, $event);
}
}
} else {
throw new Exception("Configuration for {$provider} is incomplete");
}
} catch (\Throwable $e) {
Hybrid_Auth::logoutAllProviders();
throw new HybridAuthError($e->getMessage());
}
}
}