Esempio n. 1
0
         $args = array('oauth2' => $oauth2);
         $url = absolute_url(url_for('login', $args));
         $provider = Users\OAuth2Providers::createProvider($oauth2, $url);
         $user = Users\UserOAuth2::tryLogin(db(), $provider, $url);
     } else {
         if ($openid) {
             // we want to add the openid identity URL to the return address
             // (the return URL is also verified in validate())
             $args = array("openid" => $openid);
             if ($autologin) {
                 $args["autologin"] = $autologin;
             }
             if ($destination) {
                 $args["destination"] = $destination;
             }
             $user = Users\UserOpenID::tryLogin(db(), $openid, absolute_url(url_for('login', $args)));
         } else {
             if ($email && $password) {
                 // email/password login
                 $user = Users\UserPassword::tryLogin(db(), $email, $password);
             }
         }
     }
 } catch (UserAuthenticationMissingAccountException $e) {
     $errors[] = $e->getMessage() . " " . t("You may need to :signup.", array(':signup' => link_to(url_for('signup', array('openid' => $openid, 'email' => $email)), t("signup first"))));
 } catch (UserAuthenticationException $e) {
     $errors[] = $e->getMessage();
 }
 if ($user && !$errors) {
     $user->persist(db());
     complete_login($user, $autologin);
Esempio n. 2
0
         $args = array('oauth2' => $oauth2);
         $url = absolute_url(url_for('signup', $args));
         $provider = Users\OAuth2Providers::createProvider($oauth2, $url);
         $user = Users\UserOAuth2::trySignup(db(), $provider, $url);
     } else {
         if ($openid) {
             // try OpenID signup
             // we want to add the openid identity URL to the return address
             // (the return URL is also verified in validate())
             $args = array('openid' => $openid, 'submit' => 1, 'name' => $name, 'email' => $email, 'country' => $country, 'agree' => $agree, 'subscribe' => $subscribe);
             // persist session ID (to keep referer) if the user hasn't saved cookie
             if (session_name()) {
                 $args[session_name()] = session_id();
             }
             $url = absolute_url(url_for('signup', $args));
             $user = Users\UserOpenID::trySignup(db(), $email, $openid, $url);
         } else {
             if ($email && $password) {
                 // try email/password signup
                 $user = Users\UserPassword::trySignup(db(), $email, $password);
             }
         }
     }
 } catch (\Users\UserAlreadyExistsException $e) {
     $errors[] = $e->getMessage() . " " . t("Did you mean to :login?", array(':login' => link_to(url_for('login', array('use_password' => true, 'email' => $email, 'openid' => $openid)), t("login instead"))));
 } catch (\Users\UserSignupException $e) {
     $errors[] = $e->getMessage();
 } catch (\Users\UserAuthenticationException $e) {
     $errors[] = $e->getMessage();
 }
 if ($user && !$errors) {