/** * Create an admin account. Will prompt for email address and password. */ public function executeCreateAdmin() { do { if (!empty($email_input)) { $this->out('That is not a valid email.'); } $email_input = $this->readline('Email: '); } while (!($email = Scrub::email($email_input))); do { $password = $this->readline('Password: '******'success']) { $user = UserModel::loadById($res['data']); $user->setType(UserModel::TYPE_ADMIN); } else { $this->out('Failed to create user.'); } }
/** * Create the default logged in user. * * @return User * The currently logged in user. */ public static function createInstance() { // If a session is found. $session = SessionTool::getInstance(true, false); if ($session && $session->user_id > 0) { // If we are logged into someone elses account. if ($impersonate = $session->getSetting('impersonate')) { $user = User::loadById($impersonate); } else { // Try to load the user on this session. $user = User::loadById($session->user_id); } } if (!empty($user)) { return $user; } else { // No user was found. return User::anonymous(); } }