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


PHP common_set_user函数代码示例

本文整理汇总了PHP中common_set_user函数的典型用法代码示例。如果您正苦于以下问题:PHP common_set_user函数的具体用法?PHP common_set_user怎么用?PHP common_set_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: checkLogin

 function checkLogin($user_id = null, $token = null)
 {
     // XXX: login throttle
     //database use nickname we change it into username for more
     //easier to understand
     $nickname = $this->trimmed('username');
     if (empty($nickname)) {
         $this->clientError(_('username empty'));
         return;
     }
     try {
         $nickname = Nickname::normalize($nickname);
     } catch (NicknameException $e) {
         $this->clientError(_('username error'));
         return;
     }
     $password = $this->arg('password');
     $user = common_check_user($nickname, $password);
     if (!$user) {
         // TRANS: Form validation error displayed when trying to log in with incorrect credentials.
         $this->clientError(_('Incorrect username or password.'));
         return;
     }
     // success!
     if (!common_set_user($user)) {
         // TRANS: Server error displayed when during login a server error occurs.
         $this->serverError(_('Error setting user. You are probably not authorized.'));
         return;
     }
     common_real_login(true);
     $result = $this->twitterUserArray($user->getProfile(), false);
     $this->initDocument('json');
     $this->showJsonObjects($result);
     $this->endDocument('json');
 }
开发者ID:jianoll,项目名称:SpeakEnglish_Server,代码行数:35,代码来源:apiaccountlogin.php

示例2: doPost

 /**
  * Check the login data
  *
  * Determines if the login data is valid. If so, logs the user
  * in, and redirects to the 'with friends' page, or to the stored
  * return-to URL.
  *
  * @return void
  */
 protected function doPost()
 {
     // XXX: login throttle
     $nickname = $this->trimmed('nickname');
     $password = $this->arg('password');
     $user = common_check_user($nickname, $password);
     if (!$user instanceof User) {
         // TRANS: Form validation error displayed when trying to log in with incorrect credentials.
         throw new ServerException(_('Incorrect username or password.'));
     }
     // success!
     if (!common_set_user($user)) {
         // TRANS: Server error displayed when during login a server error occurs.
         throw new ServerException(_('Error setting user. You are probably not authorized.'));
     }
     common_real_login(true);
     $this->updateScopedProfile();
     if ($this->boolean('rememberme')) {
         common_rememberme($user);
     }
     $url = common_get_returnto();
     if ($url) {
         // We don't have to return to it again
         common_set_returnto(null);
         $url = common_inject_session($url);
     } else {
         $url = common_local_url('all', array('nickname' => $this->scoped->nickname));
     }
     common_redirect($url, 303);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:39,代码来源:login.php

示例3: logout

 function logout()
 {
     common_set_user(null);
     common_real_login(false);
     // not logged in
     common_forgetme();
     // don't log back in!
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:8,代码来源:logout.php

示例4: handle

 /**
  * Class handler.
  * 
  * @param array $args array of arguments
  *
  * @return nothing
  */
 function handle($args)
 {
     parent::handle($args);
     if (!common_logged_in()) {
         $this->clientError(_('Not logged in.'));
     } else {
         common_set_user(null);
         common_real_login(false);
         // not logged in
         common_forgetme();
         // don't log back in!
         common_redirect(common_local_url('public'));
     }
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:21,代码来源:logout.php

示例5: handle

 function handle($args)
 {
     parent::handle($args);
     if (common_is_real_login()) {
         // TRANS: Client error displayed when trying to log in while already logged on.
         $this->clientError(_m('Already logged in.'));
     } else {
         global $casSettings;
         phpCAS::client(CAS_VERSION_2_0, $casSettings['server'], $casSettings['port'], $casSettings['path'], false);
         phpCAS::setNoCasServerValidation();
         phpCAS::handleLogoutRequests();
         phpCAS::forceAuthentication();
         global $casTempPassword;
         $casTempPassword = common_good_rand(16);
         $user = common_check_user(phpCAS::getUser(), $casTempPassword);
         if (!$user) {
             // TRANS: Server error displayed when trying to log in with incorrect username or password.
             $this->serverError(_m('Incorrect username or password.'));
             return;
         }
         // success!
         if (!common_set_user($user)) {
             // TRANS: Server error displayed when login fails in CAS authentication plugin.
             $this->serverError(_m('Error setting user. You are probably not authorized.'));
             return;
         }
         common_real_login(true);
         $url = common_get_returnto();
         if ($url) {
             // We don't have to return to it again
             common_set_returnto(null);
         } else {
             if (common_config('site', 'private') && $casSettings['takeOverLogin']) {
                 //SSO users expect to just go to the URL they entered
                 //if we don't have a returnto set, the user entered the
                 //main StatusNet url, so send them there.
                 $url = common_local_url('public');
             } else {
                 //With normal logins (regular form-based username/password),
                 //the user would expect to go to their home after logging in.
                 $url = common_local_url('public', array('nickname' => $user->nickname));
             }
         }
         common_redirect($url, 303);
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:46,代码来源:caslogin.php

示例6: deleteAccount

 /**
  * Delete the current user's account
  *
  * Checks for the "I am sure." string to make sure the user really
  * wants to delete their account.
  *
  * Then, marks the account as deleted and begins the deletion process
  * (actually done by a back-end handler).
  *
  * If successful it logs the user out, and shows a brief completion message.
  *
  * @return void
  */
 function deleteAccount()
 {
     $this->checkSessionToken();
     // !!! If this string is changed, it also needs to be changed in DeleteAccountForm::formData()
     // TRANS: Confirmation text for user deletion. The user has to type this exactly the same, including punctuation.
     $iamsure = _('I am sure.');
     if ($this->trimmed('iamsure') != $iamsure) {
         // TRANS: Notification for user about the text that must be input to be able to delete a user account.
         // TRANS: %s is the text that needs to be input.
         $this->_error = sprintf(_('You must write "%s" exactly in the box.'), $iamsure);
         $this->showPage();
         return;
     }
     $cur = common_current_user();
     // Mark the account as deleted and shove low-level deletion tasks
     // to background queues. Removing a lot of posts can take a while...
     if (!$cur->hasRole(Profile_role::DELETED)) {
         $cur->grantRole(Profile_role::DELETED);
     }
     $qm = QueueManager::get();
     $qm->enqueue($cur, 'deluser');
     // The user is really-truly logged out
     common_set_user(null);
     common_real_login(false);
     // not logged in
     common_forgetme();
     // don't log back in!
     $this->_complete = true;
     $this->showPage();
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:43,代码来源:deleteaccount.php

示例7: tryLogin

 function tryLogin()
 {
     common_debug(sprintf('Trying login for Facebook user %s', $this->fbuid), __FILE__);
     $flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_SERVICE);
     if (!empty($flink)) {
         $user = $flink->getUser();
         if (!empty($user)) {
             common_log(LOG_INFO, sprintf('Logged in Facebook user %s as user %d (%s)', $this->fbuid, $user->nickname, $user->id), __FILE__);
             common_set_user($user);
             common_real_login(true);
             $this->goHome($user->nickname);
         }
     } else {
         common_debug(sprintf('No flink found for fbuid: %s - new user', $this->fbuid), __FILE__);
         $this->showForm(null, $this->bestNewNickname());
     }
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:17,代码来源:facebookfinishlogin.php

示例8: tryLogin

 function tryLogin()
 {
     common_debug('TwitterBridge Plugin - ' . "Trying login for Twitter user {$this->twuid}.");
     $flink = Foreign_link::getByForeignID($this->twuid, TWITTER_SERVICE);
     if (!empty($flink)) {
         $user = $flink->getUser();
         if (!empty($user)) {
             common_debug('TwitterBridge Plugin - ' . "Logged in Twitter user {$flink->foreign_id} as user {$user->id} ({$user->nickname})");
             common_set_user($user);
             common_real_login(true);
             $this->goHome($user->nickname);
         }
     } else {
         common_debug('TwitterBridge Plugin - ' . "No flink found for twuid: {$this->twuid} - new user");
         $this->showForm(null, $this->bestNewNickname());
     }
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:17,代码来源:twitterauthorization.php

示例9: tryRegister

 /**
  * Try to register a user
  *
  * Validates the input and tries to save a new user and profile
  * record. On success, shows an instructions page.
  *
  * @return void
  */
 function tryRegister()
 {
     if (Event::handle('StartRegistrationTry', array($this))) {
         $token = $this->trimmed('token');
         if (!$token || $token != common_session_token()) {
             $this->showForm(_('There was a problem with your session token. ' . 'Try again, please.'));
             return;
         }
         $nickname = $this->trimmed('nickname');
         $email = $this->trimmed('email');
         $fullname = $this->trimmed('fullname');
         $homepage = $this->trimmed('homepage');
         $bio = $this->trimmed('bio');
         $location = $this->trimmed('location');
         // We don't trim these... whitespace is OK in a password!
         $password = $this->arg('password');
         $confirm = $this->arg('confirm');
         // invitation code, if any
         $code = $this->trimmed('code');
         if ($code) {
             $invite = Invitation::staticGet($code);
         }
         if (common_config('site', 'inviteonly') && !($code && $invite)) {
             $this->clientError(_('Sorry, only invited people can register.'));
             return;
         }
         // Input scrubbing
         try {
             $nickname = Nickname::normalize($nickname);
         } catch (NicknameException $e) {
             $this->showForm($e->getMessage());
         }
         $email = common_canonical_email($email);
         if (!$this->boolean('license')) {
             $this->showForm(_('You cannot register if you don\'t ' . 'agree to the license.'));
         } else {
             if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
                 $this->showForm(_('Not a valid email address.'));
             } else {
                 if ($this->nicknameExists($nickname)) {
                     $this->showForm(_('Nickname already in use. Try another one.'));
                 } else {
                     if (!User::allowed_nickname($nickname)) {
                         $this->showForm(_('Not a valid nickname.'));
                     } else {
                         if ($this->emailExists($email)) {
                             $this->showForm(_('Email address already exists.'));
                         } else {
                             if (!is_null($homepage) && strlen($homepage) > 0 && !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
                                 $this->showForm(_('Homepage is not a valid URL.'));
                                 return;
                             } else {
                                 if (!is_null($fullname) && mb_strlen($fullname) > 255) {
                                     $this->showForm(_('Full name is too long (maximum 255 characters).'));
                                     return;
                                 } else {
                                     if (Profile::bioTooLong($bio)) {
                                         $this->showForm(sprintf(_m('Bio is too long (maximum %d character).', 'Bio is too long (maximum %d characters).', Profile::maxBio()), Profile::maxBio()));
                                         return;
                                     } else {
                                         if (!is_null($location) && mb_strlen($location) > 255) {
                                             $this->showForm(_('Location is too long (maximum 255 characters).'));
                                             return;
                                         } else {
                                             if (strlen($password) < 6) {
                                                 $this->showForm(_('Password must be 6 or more characters.'));
                                                 return;
                                             } else {
                                                 if ($password != $confirm) {
                                                     $this->showForm(_('Passwords don\'t match.'));
                                                 } else {
                                                     if ($user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, 'location' => $location, 'code' => $code))) {
                                                         if (!$user) {
                                                             $this->showForm(_('Invalid username or password.'));
                                                             return;
                                                         }
                                                         // success!
                                                         if (!common_set_user($user)) {
                                                             $this->serverError(_('Error setting user.'));
                                                             return;
                                                         }
                                                         // this is a real login
                                                         common_real_login(true);
                                                         if ($this->boolean('rememberme')) {
                                                             common_debug('Adding rememberme cookie for ' . $nickname);
                                                             common_rememberme($user);
                                                         }
                                                         Event::handle('EndRegistrationTry', array($this));
                                                         // Re-init language env in case it changed (not yet, but soon)
                                                         common_init_language();
                                                         $this->showSuccess();
                                                     } else {
//.........这里部分代码省略.........
开发者ID:microcosmx,项目名称:experiments,代码行数:101,代码来源:register.php

示例10: tryRegister

 /**
  * Try to register a user
  *
  * Validates the input and tries to save a new user and profile
  * record. On success, shows an instructions page.
  *
  * @return void
  */
 function tryRegister()
 {
     if (Event::handle('StartRegistrationTry', array($this))) {
         $token = $this->trimmed('token');
         if (!$token || $token != common_session_token()) {
             // TRANS: Client error displayed when the session token does not match or is not given.
             $this->showForm(_('There was a problem with your session token. ' . 'Try again, please.'));
             return;
         }
         $nickname = $this->trimmed('nickname');
         $email = $this->trimmed('email');
         $fullname = $this->trimmed('fullname');
         $homepage = $this->trimmed('homepage');
         $bio = $this->trimmed('bio');
         $location = $this->trimmed('location');
         // We don't trim these... whitespace is OK in a password!
         $password = $this->arg('password');
         $confirm = $this->arg('confirm');
         // invitation code, if any
         $code = $this->trimmed('code');
         if ($code) {
             $invite = Invitation::getKV($code);
         }
         if (common_config('site', 'inviteonly') && !($code && $invite)) {
             // TRANS: Client error displayed when trying to register to an invite-only site without an invitation.
             $this->clientError(_('Sorry, only invited people can register.'));
         }
         // Input scrubbing
         try {
             $nickname = Nickname::normalize($nickname, true);
         } catch (NicknameException $e) {
             $this->showForm($e->getMessage());
             return;
         }
         $email = common_canonical_email($email);
         if (!$this->boolean('license')) {
             // TRANS: Form validation error displayed when trying to register without agreeing to the site license.
             $this->showForm(_('You cannot register if you do not ' . 'agree to the license.'));
         } else {
             if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
                 // TRANS: Form validation error displayed when trying to register without a valid e-mail address.
                 $this->showForm(_('Not a valid email address.'));
             } else {
                 if ($this->emailExists($email)) {
                     // TRANS: Form validation error displayed when trying to register with an already registered e-mail address.
                     $this->showForm(_('Email address already exists.'));
                 } else {
                     if (!is_null($homepage) && strlen($homepage) > 0 && !common_valid_http_url($homepage)) {
                         // TRANS: Form validation error displayed when trying to register with an invalid homepage URL.
                         $this->showForm(_('Homepage is not a valid URL.'));
                     } else {
                         if (!is_null($fullname) && mb_strlen($fullname) > 255) {
                             // TRANS: Form validation error displayed when trying to register with a too long full name.
                             $this->showForm(_('Full name is too long (maximum 255 characters).'));
                         } else {
                             if (Profile::bioTooLong($bio)) {
                                 // TRANS: Form validation error on registration page when providing too long a bio text.
                                 // TRANS: %d is the maximum number of characters for bio; used for plural.
                                 $this->showForm(sprintf(_m('Bio is too long (maximum %d character).', 'Bio is too long (maximum %d characters).', Profile::maxBio()), Profile::maxBio()));
                             } else {
                                 if (!is_null($location) && mb_strlen($location) > 255) {
                                     // TRANS: Form validation error displayed when trying to register with a too long location.
                                     $this->showForm(_('Location is too long (maximum 255 characters).'));
                                 } else {
                                     if (strlen($password) < 6) {
                                         // TRANS: Form validation error displayed when trying to register with too short a password.
                                         $this->showForm(_('Password must be 6 or more characters.'));
                                     } else {
                                         if ($password != $confirm) {
                                             // TRANS: Form validation error displayed when trying to register with non-matching passwords.
                                             $this->showForm(_('Passwords do not match.'));
                                         } else {
                                             try {
                                                 $user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, 'location' => $location, 'code' => $code));
                                                 // success!
                                                 if (!common_set_user($user)) {
                                                     // TRANS: Server error displayed when saving fails during user registration.
                                                     $this->serverError(_('Error setting user.'));
                                                 }
                                                 // this is a real login
                                                 common_real_login(true);
                                                 if ($this->boolean('rememberme')) {
                                                     common_debug('Adding rememberme cookie for ' . $nickname);
                                                     common_rememberme($user);
                                                 }
                                                 // Re-init language env in case it changed (not yet, but soon)
                                                 common_init_language();
                                                 Event::handle('EndRegistrationTry', array($this));
                                                 $this->showSuccess();
                                             } catch (Exception $e) {
                                                 // TRANS: Form validation error displayed when trying to register with an invalid username or password.
                                                 $this->showForm($e->getMessage());
//.........这里部分代码省略.........
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:101,代码来源:register.php

示例11: handle

 function handle($args)
 {
     parent::handle($args);
     if (!Event::handle('StartRegistrationTry', array($this))) {
         return;
     }
     //database use nickname we change it into username for more
     //easier to understand
     $nickname = $this->trimmed('username');
     $email = $this->trimmed('email');
     $fullname = $this->trimmed('nickname');
     $homepage = NULL;
     //$this->trimmed('homepage');
     $bio = $this->trimmed('description');
     $location = $this->trimmed('location');
     $genderStr = $this->trimmed('gender');
     if (!empty($bio)) {
         if (mb_strlen($bio) > self::MAX_DESCRIPTION) {
             $this->clientError(_('description must be set less than 70'));
             return;
         }
     }
     if (empty($email) && empty($nickname)) {
         $this->clientError(_('must set nickname or email'));
         return;
     }
     if (empty($nickname) && !empty($email)) {
         $user_email_check = User::staticGet('email', $email);
         if ($user_email_check) {
             $this->clientError(_('email exists'));
             return;
         }
         $nickname = $this->nicknameFromEmail($email);
     }
     // We don't trim these... whitespace is OK in a password!
     $password = $this->arg('password');
     try {
         $nickname = Nickname::normalize($nickname);
     } catch (NicknameException $e) {
         $this->clientError(_('username error'));
         return;
     }
     if (!User::allowed_nickname($nickname)) {
         // TRANS: Client error displayed when trying to create a new user with an invalid username.
         $this->clientError(_('username bad'), 400);
         return;
     }
     $gender = 0;
     if (!empty($genderStr)) {
         if ($genderStr == 'f') {
             $gender = 1;
         } else {
             if ($genderStr == 'm') {
                 $gender = 2;
             }
         }
     }
     $user_check = User::staticGet('nickname', $nickname);
     if ($user_check) {
         $this->clientError('username exists', 400);
         return;
     }
     if (empty($password)) {
         $this->clientError(_('password empty'), 400);
         return;
     }
     //no need to confirmed email
     $email_confirmed = !empty($email);
     $user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, 'location' => $location, 'code' => $code, 'gender' => $gender, 'email_confirmed' => $email_confirmed));
     if (!$user) {
         // TRANS: Form validation error displayed when trying to register with an invalid username or password.
         $this->clientError(_('Invalid username or password.', 400, 'json'));
         return;
     }
     // success!
     if (!common_set_user($user)) {
         // TRANS: Server error displayed when saving fails during user registration.
         $this->serverError(_('Error setting user.', '500', 'json'));
         return;
     }
     // this is a real login
     common_real_login(true);
     if ($this->boolean('rememberme')) {
         common_debug('Adding rememberme cookie for ' . $nickname);
         common_rememberme($user);
     }
     // Re-init language env in case it changed (not yet, but soon)
     common_init_language();
     Event::handle('EndRegistrationTry', array($this));
     $resultUser = $this->twitterUserArray($user->getProfile(), false);
     $this->initDocument('json');
     $this->showJsonObjects($resultUser);
     $this->endDocument('json');
 }
开发者ID:jianoll,项目名称:SpeakEnglish_Server,代码行数:94,代码来源:apiaccountregister.php

示例12: tryLogin

 function tryLogin()
 {
     $flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_SERVICE);
     if (!empty($flink)) {
         $user = $flink->getUser();
         if (!empty($user)) {
             common_log(LOG_INFO, sprintf('Logged in Facebook user %s as user %d (%s)', $this->fbuid, $user->nickname, $user->id), __FILE__);
             common_set_user($user);
             common_real_login(true);
             // clear out the stupid cookie
             setcookie('fb_access_token', '', time() - 3600);
             // one hour ago
             $this->goHome($user->nickname);
         }
     } else {
         $this->showForm(null, $this->bestNewNickname());
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:18,代码来源:facebookfinishlogin.php

示例13: tryRegister

 /**
  * Try to register a user
  *
  * Validates the input and tries to save a new user and profile
  * record. On success, shows an instructions page.
  *
  * @return void
  */
 function tryRegister()
 {
     if (Event::handle('StartRegistrationTry', array($this))) {
         $token = $this->trimmed('token');
         if (!$token || $token != common_session_token()) {
             // TRANS: Client error displayed when the session token does not match or is not given.
             $this->showForm(_('There was a problem with your session token. ' . 'Try again, please.'));
             return;
         }
         $privatekey = "6LfbNe0SAAAAAMlC0ByC2IHKH8LKatPNX8HaMGGH";
         $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         if (!$resp->is_valid) {
             // What happens when the CAPTCHA was entered incorrectly
             $this->showForm(_("El reCAPTCHA no se ha introducido correctamente."));
         } else {
             if ($this->trimmed('phoneLbl') != "") {
                 return;
             }
             $nickname = $this->trimmed('nickname');
             $email = $this->trimmed('email');
             $fullname = $this->trimmed('fullname');
             // We don't trim these... whitespace is OK in a password!
             $password = $this->arg('password');
             $confirm = $this->arg('confirm');
             // invitation code, if any
             $code = $this->trimmed('code');
             if ($code) {
                 $invite = Invitation::staticGet($code);
             }
             if (common_config('site', 'inviteonly') && !($code && $invite)) {
                 // TRANS: Client error displayed when trying to register to an invite-only site without an invitation.
                 $this->clientError(_('Sorry, only invited people can register.'));
                 return;
             }
             // Input scrubbing
             try {
                 $nickname = Nickname::normalize($nickname);
             } catch (NicknameException $e) {
                 $this->showForm($e->getMessage());
                 return;
             }
             $email = common_canonical_email($email);
             if (!$this->boolean('license')) {
                 // TRANS: Form validation error displayed when trying to register without agreeing to the site license.
                 $this->showForm(_('You cannot register if you do not ' . 'agree to the license.'));
             } else {
                 if (!$email) {
                     $this->showForm(_("Email can't be empty"));
                 } else {
                     if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
                         // TRANS: Form validation error displayed when trying to register without a valid e-mail address.
                         $this->showForm(_('Not a valid email address.'));
                     } else {
                         if ($this->nicknameExists($nickname)) {
                             // TRANS: Form validation error displayed when trying to register with an existing nickname.
                             $this->showForm(_('Nickname already in use. Try another one.'));
                         } else {
                             if (!User::allowed_nickname($nickname)) {
                                 // TRANS: Form validation error displayed when trying to register with an invalid nickname.
                                 $this->showForm(_('Not a valid nickname.'));
                             } else {
                                 if ($this->emailExists($email)) {
                                     // TRANS: Form validation error displayed when trying to register with an already registered e-mail address.
                                     $this->showForm(_('Email address already exists.'));
                                 } else {
                                     if (!is_null($fullname) && mb_strlen($fullname) > 255) {
                                         // TRANS: Form validation error displayed when trying to register with a too long full name.
                                         $this->showForm(_('Full name is too long (maximum 255 characters).'));
                                         return;
                                     } else {
                                         if (strlen($password) < 6) {
                                             // TRANS: Form validation error displayed when trying to register with too short a password.
                                             $this->showForm(_('Password must be 6 or more characters.'));
                                             return;
                                         } else {
                                             if ($password != $confirm) {
                                                 // TRANS: Form validation error displayed when trying to register with non-matching passwords.
                                                 $this->showForm(_('Passwords do not match.'));
                                             } else {
                                                 if ($user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, 'location' => $location, 'code' => $code))) {
                                                     if (!$user) {
                                                         // TRANS: Form validation error displayed when trying to register with an invalid username or password.
                                                         $this->showForm(_('Invalid username or password.'));
                                                         return;
                                                     }
                                                     // success!
                                                     if (!common_set_user($user)) {
                                                         // TRANS: Server error displayed when saving fails during user registration.
                                                         $this->serverError(_('Error setting user.'));
                                                         return;
                                                     }
                                                     // this is a real login
//.........这里部分代码省略.........
开发者ID:Grasia,项目名称:bolotweet,代码行数:101,代码来源:SecureregisterAction.php

示例14: setPassword

 function setPassword()
 {
     if (Event::handle('StartRegistrationTry', array($this))) {
         if (!empty($this->invitation)) {
             $email = trim($this->invitation->address);
         } else {
             if (!empty($this->confirmation)) {
                 $email = trim($this->confirmation->address);
             } else {
                 // TRANS: Client exception trown when trying to set password with an invalid confirmation code.
                 throw new Exception(_m('No confirmation thing.'));
             }
         }
         if (!$this->tos) {
             // TRANS: Error text when trying to register without agreeing to the terms.
             $this->error = _m('You must accept the terms of service and privacy policy to register.');
         } else {
             if (empty($this->password1)) {
                 // TRANS: Error text when trying to register without a password.
                 $this->error = _m('You must set a password');
             } else {
                 if (strlen($this->password1) < 6) {
                     // TRANS: Error text when trying to register with too short a password.
                     $this->error = _m('Password must be 6 or more characters.');
                 } else {
                     if ($this->password1 != $this->password2) {
                         // TRANS: Error text when trying to register without providing the same password twice.
                         $this->error = _m('Passwords do not match.');
                     }
                 }
             }
         }
         if (!empty($this->error)) {
             $this->form = new ConfirmRegistrationForm($this, $this->nickname, $email, $this->code);
             $this->showPage();
             return;
         }
         try {
             $fields = array('nickname' => $this->nickname, 'email' => $email, 'password' => $this->password1, 'email_confirmed' => true);
             if (!empty($this->invitation)) {
                 $fields['code'] = $this->invitation->code;
             }
             $this->user = User::register($fields);
         } catch (ClientException $e) {
             $this->error = $e->getMessage();
             $this->form = new ConfirmRegistrationForm($this, $this->nickname, $email, $this->code);
             $this->showPage();
             return;
         }
         if (empty($this->user)) {
             // TRANS: Exception trown when using an invitation multiple times.
             throw new Exception(_m('Failed to register user.'));
         }
         common_set_user($this->user);
         // this is a real login
         common_real_login(true);
         // Re-init language env in case it changed (not yet, but soon)
         common_init_language();
         if (!empty($this->confirmation)) {
             $this->confirmation->delete();
         }
         Event::handle('EndRegistrationTry', array($this));
     }
     if (Event::handle('StartRegisterSuccess', array($this))) {
         Event::handle('EndRegisterSuccess', array($this));
         common_redirect(common_local_url('doc', array('title' => 'welcome')), 303);
         // common_redirect exits, so we can't run the event _after_ it of course.
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:69,代码来源:emailregister.php

示例15: resetPassword

 function resetPassword()
 {
     # CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         $this->showForm(_('There was a problem with your session token. Try again, please.'));
         return;
     }
     $user = $this->getTempUser();
     if (!$user) {
         $this->clientError(_('Unexpected password reset.'));
         return;
     }
     $newpassword = $this->trimmed('newpassword');
     $confirm = $this->trimmed('confirm');
     if (!$newpassword || strlen($newpassword) < 6) {
         $this->showPasswordForm(_('Password must be 6 chars or more.'));
         return;
     }
     if ($newpassword != $confirm) {
         $this->showPasswordForm(_('Password and confirmation do not match.'));
         return;
     }
     # OK, we're ready to go
     $original = clone $user;
     $user->password = common_munge_password($newpassword, $user->id);
     if (!$user->update($original)) {
         common_log_db_error($user, 'UPDATE', __FILE__);
         $this->serverError(_('Can\'t save new password.'));
         return;
     }
     $this->clearTempUser();
     if (!common_set_user($user->nickname)) {
         $this->serverError(_('Error setting user.'));
         return;
     }
     common_real_login(true);
     $this->mode = 'saved';
     $this->msg = _('New password successfully saved. ' . 'You are now logged in.');
     $this->success = true;
     $this->showPage();
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:42,代码来源:recoverpassword.php


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