// Try to get an access token try { $token = $obj->getAccessToken('authorization_code', array('code' => $_GET['code'])); } catch (\League\OAuth2\Client\Exception\IDPException $e) { throw new Exception($e->getMessage()); } } $user_details = $obj->getUserDetails($token); $uid = $user_details->uid; if (Post::has('username')) { $username = Post::val('username'); } else { $username = $user_details->nickname; } // First time logging in if (!Flyspray::checkForOauthUser($uid, $provider)) { if (!$user_details->email) { Flyspray::show_error(27); } $success = false; if ($username) { $group_in = $fs->prefs['anon_group']; $name = $user_details->name ?: $username; $success = Backend::create_user($username, null, $name, '', $user_details->email, 0, 0, $group_in, 1, $uid, $provider); } // username taken or not provided, ask for it if (!$success) { $_SESSION['oauth_token'] = serialize($token); $_SESSION['oauth_provider'] = $provider; $page->assign('provider', ucfirst($provider)); $page->assign('username', $username);