Ejemplo n.º 1
0
 public static function generateCookie($uuid)
 {
     echo 'IP: ' . Utils::getClientIP();
     $model = new CookieModel();
     $token = str_shuffle(sha1(md5(HashUtils::generateString(50))));
     $toVerify = hash("sha512", $token . Utils::getClientIP());
     $model->user_uuid = $uuid;
     $model->expiry = date(DATE_FORMAT, time() + Config::get('cookie', 'timeout'));
     $model->token = $toVerify;
     Cookie::set(Config::get('cookie', 'name'), $token, Config::get('cookie', 'timeout'));
     ControllerManager::saveController(new CookieController($model));
 }
Ejemplo n.º 2
0
 public static function register($firstname, $lastname, $username, $email, $password)
 {
     if ($uuid = self::getUUIDByUsername($username)) {
         echo 'Username already Exists';
     } else {
         if ($uuid = self::getUUIDByEmail($email)) {
             echo 'Email already exists';
         } else {
             $modelClass = self::getModelClass();
             /** @var UserModel $userModel */
             $userModel = new $modelClass();
             $userModel->uuid = HashUtils::generateUUID();
             $userModel->username = $username;
             $userModel->firstname = $firstname;
             $userModel->lastname = $lastname;
             $userModel->email = $email;
             $userModel->password_hash = HashUtils::hashPassword($password);
             echo 'Registered user';
             return ControllerManager::saveController(new UserController($userModel));
         }
     }
     return false;
 }