当前位置: 首页>>代码示例>>PHP>>正文


PHP User::setLastLogin方法代码示例

本文整理汇总了PHP中AppBundle\Entity\User::setLastLogin方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setLastLogin方法的具体用法?PHP User::setLastLogin怎么用?PHP User::setLastLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppBundle\Entity\User的用法示例。


在下文中一共展示了User::setLastLogin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createAction

 public function createAction($format)
 {
     try {
         $em = $this->getDoctrine()->getManager();
         $user = new User();
         $params = array();
         $content = $this->get("request")->getContent();
         if (!empty($content)) {
             $params = json_decode($content, true);
             $user->setConfirmationToken($params['confirmationToken']);
             $user->setCredentialsExpireAt($params['credentialsExpireAt']);
             $user->setCredentialsExpired($params['credentialsExpired']);
             $user->setEmail($params['email']);
             $user->setEmailCanonical($params['emailCanonical']);
             $user->setEnabled($params['enabled']);
             $user->setExpired($params['expired']);
             $user->setExpiresAt($params['expiresAt']);
             $user->setLastLogin($params['lastLogin']);
             $user->setLocked($params['locked']);
             $user->setPassword($params['password']);
             $user->setPasswordRequestedAt($params['passwordRequestedAt']);
             $user->setRoles($params['roles']);
             $user->setSalt($params['salt']);
             $user->setUsername($params['username']);
             $user->setUsernameCanonical($params['usernameCanonical']);
         }
         $em->persist($user);
         $em->flush();
         return $this->formatResponse("ok", $format);
     } catch (Exception $ex) {
         return $this->formatResponse("error", $format);
     }
 }
开发者ID:dowrow,项目名称:Symfony-REST,代码行数:33,代码来源:UserController.php

示例2: getUser

 public function getUser($authorizationCode, UserProviderInterface $userProvider)
 {
     $provider = $this->getGoogleOAuthProvider();
     try {
         // the credentials are really the access token
         $accessToken = $provider->getAccessToken('authorization_code', ['code' => $authorizationCode]);
     } catch (IdentityProviderException $ex) {
         $response = $e->getResponseBody();
         $errorCode = $response['error']['code'];
         $message = $response['error']['message'];
         //var_dump($response);
         //TODO throw a custom error to handle ???
     }
     $googleUser = $provider->getResourceOwner($accessToken);
     $email = $googleUser->getEmail();
     $googleId = $googleUser->getId();
     $firstname = $googleUser->getFirstname();
     $lastname = $googleUser->getLastname();
     $displayName = $googleUser->getName();
     $em = $this->container->get('doctrine')->getManager();
     $user = $em->getRepository('AppBundle:User')->findOneBy(['email' => $email]);
     //If there is no user, we need to create one
     if (!$user) {
         $user = new User();
         $user->setUsername($email);
         $user->setEmail($email);
         $user->setLastname($lastname);
         $user->setFirstname($firstname);
         $user->setGoogleDisplayName($displayName);
         $user->setLocale('en_US');
         //Set to unencoded password.
         //Since passwords are encode when checked, users should not be able to login using it
         $user->setPassword('GOOGLE LOGIN');
         //Make sure that a user has at least the role of ROLE_USER when created
         $roles = $user->getRoles();
         $user->setRoles($roles);
     }
     $user->setLastLogin(new \DateTime());
     $user->setGoogleId($googleId);
     $em->persist($user);
     $em->flush();
     return $user;
 }
开发者ID:onlinespaces,项目名称:symfony-guard-project,代码行数:43,代码来源:GoogleAuthenticator.php

示例3: load

 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('karen');
     //$user->setPassword($this->encodePassword($user, 'karenpass'));
     $user->setPlainPassword('karenpass');
     $user->setApiToken('123abc');
     $user->setLocale('en_US');
     $user->setEmail('karen@onlinespaces.com');
     $user->setLastLogin(new \DateTime());
     $manager->persist($user);
     $admin = new User();
     $admin->setUsername('scott');
     //$admin->setPassword($this->encodePassword($admin, 'karenpass'));
     $admin->setPlainPassword('scottpass');
     $admin->setApiToken('DkE3KWIXPt6bnzZl6lcTt682WLhWYnLYjTeNyiZqgPJiHoEkjTtx03ECCnWP');
     $admin->setLocale('en_US');
     $admin->setRoles(array('ROLE_ADMIN'));
     $admin->setEmail('scott@onlinespaces.com');
     $admin->setLastLogin(new \DateTime());
     $manager->persist($admin);
     // the queries aren't done until now
     $manager->flush();
 }
开发者ID:onlinespaces,项目名称:symfony-guard-project,代码行数:24,代码来源:LoadUsers.php

示例4: setLastLogin

 /**
  * {@inheritDoc}
  */
 public function setLastLogin(\DateTime $time = NULL)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLastLogin', [$time]);
     return parent::setLastLogin($time);
 }
开发者ID:reathh,项目名称:MotikarqSystem,代码行数:8,代码来源:__CG__AppBundleEntityUser.php

示例5: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $uri = $this->request->getUri();
     $isMailru = false;
     if (strpos($uri, '/login_mailru') !== false) {
         $isMailru = true;
     }
     if ($isMailru === false) {
         throw new \Exception("Invalid social network login attempt");
     }
     $social = "";
     if ($isMailru) {
         $social = "mailru";
     }
     //check to see if the user is logged in and if she is logged in with the same social network
     $isLoggedInAlready = $this->session->has('user');
     $isLoggedInAlreadyId = $this->session->get('user')['id'];
     if ($isLoggedInAlready && $this->session->get('user')['social'] == $social) {
         return $this->loadUserByUsername($isLoggedInAlreadyId);
     }
     $social_id = $response->getUsername();
     $username = $response->getUsername();
     $realName = $response->getRealName();
     $email = $response->getEmail();
     $avatar = $response->getProfilePicture();
     //set data in session. upon logging out we just erase the whole array.
     $sessionData = array();
     $sessionData['social_id'] = $social_id;
     $sessionData['username'] = $username;
     $sessionData['realName'] = $realName;
     $sessionData['email'] = $email;
     $sessionData['avatar'] = $avatar;
     $sessionData['social'] = $social;
     $user = null;
     if ($isLoggedInAlready) {
         $user = $this->doctrine->getRepository('AppBundle\\Entity\\User')->findOneById($isLoggedInAlreadyId);
     } else {
         if ($isMailru) {
             $user = $this->doctrine->getRepository('AppBundle\\Entity\\User')->findOneByMid($social_id);
         }
     }
     if ($user == null) {
         $user = new User();
         //change these only the user hasn't been registered before.
         $user->setUsername($username);
         $user->setRealname($realName);
         $user->setAvatar($avatar);
     }
     if ($isMailru) {
         $user->setMid($social_id);
     }
     $user->setLastLogin(new \DateTime('now'));
     $user->setSocial($social);
     // SET E-MAIL
     //if all emails are empty, set the first one to this one.
     if ($user->getEmail() == "") {
         $user->setEmail($email);
     } else {
         //if it really is an e-mail, try putting it in email2 or email3
         if ($email != "") {
             //is the e-mail different than the previous one?
             if ($email != $user->getEmail()) {
                 //if there an e-mail in email2? no:
                 if ($user->getEmail2() == "") {
                     $user->setEmail2($email);
                 } else {
                     //there is an e-mail in email2 and it's different. fall back to setting the user3 to w/e.
                     if ($user->getEmail2() != $email) {
                         $user->setEmail3($email);
                     }
                 }
             }
         }
     }
     //save all changes
     $em = $this->doctrine->getManager();
     $em->persist($user);
     $em->flush();
     $id = $user->getId();
     //set id
     $sessionData['id'] = $id;
     $sessionData['is_admin'] = $this->adminChecker->check($user);
     $this->session->set('user', $sessionData);
     return $this->loadUserByUsername($user->getId());
 }
开发者ID:busaev,项目名称:s3,代码行数:85,代码来源:Provider.php


注:本文中的AppBundle\Entity\User::setLastLogin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。