} 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); // redirect if (!$destination) { $destination = url_for(get_site_config('default_login')); }
} 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) { $user_instance = $user; $q = db()->prepare("INSERT INTO user_properties SET\n id=:id,\n name=:name, country=:country, user_ip=:ip, referer=:referer, subscribe_announcements=:subscribe, created_at=NOW(), updated_at=NOW()"); $user = array("id" => $user->getId(), "name" => $name, "country" => $country, "ip" => user_ip(), "referer" => isset($_SESSION['referer']) ? substr($_SESSION['referer'], 0, 250) : NULL, "subscribe" => $subscribe ? 1 : 0); $q->execute($user);