Example #1
0
 /**
  * Used on github authorization between projects and users (see github.js)
  * Code moved from the old /GitHub.php file
  */
 public function connect()
 {
     $GitHub = new User(Session::uid());
     $workitem = new WorkItem();
     $workitem->loadById((int) $_GET['job']);
     $projectId = $workitem->getProjectId();
     $project = new Project($projectId);
     $connectResponse = $GitHub->processConnectResponse($project);
     if (!$connectResponse['error']) {
         if ($GitHub->storeCredentials($connectResponse['data']['access_token'], $project->getGithubId())) {
             $journal_message = sprintf("%s has been validated for project ##%s##", $GitHub->getNickname(), $project->getName());
             Utils::systemNotification($journal_message);
             Utils::redirect('./' . $workitem->getId());
         } else {
             // Something went wrong updating the users details, close this window and
             // display a proper error message to the user
             $message = 'Something went wrong and we could not complete the authorization process with GitHub. Please try again.';
         }
     } else {
         // We have an error on the response, close this window and display an error message
         // to the user
         $message = 'We received an error when trying to complete the authorization process with GitHub. Please notify a member of the O-Team for assistance.';
     }
     echo $message;
 }
Example #2
0
 public static function signup($username, $nickname, $password, $access_token, $country)
 {
     $sql = "\n            INSERT\n            INTO " . USERS . " (username, nickname, password, confirm_string, added, w9_status, country, is_active)\n            VALUES(\n                '" . mysql_real_escape_string($username) . "',\n                '" . mysql_real_escape_string($nickname) . "',\n                '{crypt}" . mysql_real_escape_string(Utils::encryptPassword($password)) . "',\n                '" . uniqid() . "',\n                NOW(),\n                'not-applicable',\n                '" . mysql_real_escape_string($country) . "',\n                0\n            )";
     $res = mysql_query($sql);
     $user_id = mysql_insert_id();
     if (!$user_id) {
         return false;
     }
     $ret = new User($user_id);
     if ($ret->getId() && !$ret->isGithub_connected()) {
         $ret->storeCredentials($access_token);
     }
     return $ret;
 }