$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);