/** * Store a newly created user in storage. * * @return Response */ public function store() { /* Fetching inputs and creating model */ $user = new User(); $id = mt_rand(); Input::merge(['profile_url' => $id, 'fresh' => '1']); if (Input::get('type') == 'charity') { Input::merge(['approved' => '1']); } if ($user->save()) { /* Generate activation code */ $activation = new Activation(); $activation->generate($user); $activation->save(); /* Queueing email */ $m = new Mailer(); $m->send($user, 'emails.activation', array('code' => $activation->code), array('subject' => 'Music Equity Account Activation', 'from' => '*****@*****.**')); return Response::json(array('success' => true)); } else { return Response::json($user->errors()); } }
public static function createNewUser($username, $password = null, $email) { $db = Database::getDatabase(); if (Auth::userExists($username)) { return false; } if (is_null($password)) { $password = Auth::generateStrongPassword(); } srand(time()); $u = new User(); $u->username = $username; $u->nid = self::newNid(); $u->password = self::hashedPassword($password); $u->email = $email; $u->insert(); // Create the activation code Activation::generate($u->id, 20); return $u; }
if (Options::exists($dateOption)) { // Compare the posted value to the value in the DB and update it if neccesarry if (htmlspecialchars(Options::userGet($userId, $dateOption)) !== htmlspecialchars($timestamp)) { // Set the option to the new value Options::userSet($userId, $dateOption, $timestamp); $changes = true; } } } if (isset($_POST['action']) && $_POST['action'] == 'Save Changes') { // These are the 2 static things in your account a password and a email address if (isset($_POST['user-email']) && $Error->email($_POST['user-email'], false) && $_POST['user-email'] !== $u->email) { $u->email = $_POST['user-email']; $u->update(); Activation::remove($userId); $link = full_url_to_script('activate.php') . "?action=activate&code=" . Activation::generate($userId) . "&id=" . $userId; Emailtemplate::setBaseDir('./assets/email_templates'); $html = Emailtemplate::loadTemplate('reactivate', array('title' => 'Reactivation Email', 'prettyName' => Options::get('prettyName'), 'name' => $u->username, 'siteName' => Options::get('emailName'), 'activationLink' => $link, 'footerLink' => Options::get('siteName'), 'footerEmail' => Options::get('emailInfo'))); send_html_mail(array($u->username => $u->email), 'Reactivation Email', $html, array(Options::get('siteName') => Options::get('emailAdmin'))); $Error->add('info', '<strong>Logged Out</strong><br />We have sent you a reactivation email to the new email address in order to verify it. Please check your email and follow the link within.'); $Auth->logout(); } // These are the 2 static things in your account a password and a email address if (isset($_POST['user-password']) && $_POST['user-password'] !== $inputValue[1] && $_POST['user-password'] !== '') { Auth::changePassword($u->id, $_POST['user-password']); $Error->add('info', '<strong>Logged Out</strong><br />Password updated, you may login with your new password'); $Auth->logout(); } } } Template::setBaseDir('./assets/tmpl');
addColumn("users", 'level', "ENUM('free', 'user', 'admin', 'moderator')", "default 'user'"); addColumn("users", 'email', "varchar(65)", "default NULL"); // Add the options table columns addColumn("options", '`type`', "ENUM('input', 'date', 'bool', 'hidden', 'textarea')", "default 'input'"); addColumn("options", '`group`', "varchar(65)", "default 'Miscellaneous'"); // This table will be where the settings are kept createTable("options_groups", "`group` varchar(65) NOT NULL", True, False); addColumn("options_groups", '`desc`', "varchar(65)", "default NULL"); // This is where we will add the clien'ts ability to add values to the settings. createTable("options_users", "user_id int(11) NOT NULL", false, false); addColumn("options_users", '`key`', "varchar(65)", "default NULL"); addColumn("options_users", 'value', "varchar(65)", "default NULL"); $defaultUser = '******'; $defaultPass = '******'; $adminEmail = '*****@*****.**'; // Create the default system user Auth::createNewUser($defaultUser, $defaultPass, $adminEmail); // Add a user, when the username does not exist Auth::changeGroup($defaultUser, 'admin'); // Promote the user to administrator by running the following snippet*/ $getId = Auth::userId($defaultUser); Activation::generate($getId, 20); Activation::activate($getId); // Set the timestamp and filesize Options::add('installModified', $lastEdit, 'hidden', 'Miscellaneous'); // Do not modify these, they need to be static Options::add('installFilesize', $fileSize, 'hidden', 'Miscellaneous'); // Do not modify these, they need to be static*/ $installRan = true; } // End of installation action