Commit 12ff225f authored by Richard Mansfield's avatar Richard Mansfield

Remove username & password from register page & change them after registration instead

parent d4976c32
This diff is collapsed.
......@@ -490,10 +490,7 @@
<TABLE NAME="usr_registration">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" SEQUENCE="true" NOTNULL="true" />
<FIELD NAME="username" TYPE="char" LENGTH="30" NOTNULL="true"/>
<FIELD NAME="password" TYPE="char" LENGTH="40" NOTNULL="true"/>
<FIELD NAME="institution" TYPE="char" LENGTH="255" NOTNULL="true"/>
<FIELD NAME="salt" TYPE="char" LENGTH="8" NOTNULL="true"/>
<FIELD NAME="firstname" TYPE="text" NOTNULL="true"/>
<FIELD NAME="lastname" TYPE="text" NOTNULL="true"/>
<FIELD NAME="email" TYPE="text" NOTNULL="true"/>
......
......@@ -1177,6 +1177,16 @@ function xmldb_core_upgrade($oldversion=0) {
ensure_record_exists('event_type', $event, $event);
}
if ($oldversion < 2009082400) {
$table = new XMLDBTable('usr_registration');
$field = new XMLDBField('username');
drop_field($table, $field);
$field = new XMLDBField('salt');
drop_field($table, $field);
$field = new XMLDBField('password');
drop_field($table, $field);
}
return $status;
}
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2009082101;
$config->version = 2009082400;
$config->release = '1.2.0beta2dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -100,15 +100,14 @@ if (isset($key)) {
}
$user = new User();
$user->username = $registration->username;
$user->password = $registration->password;
$user->salt = $registration->salt;
$user->passwordchange = 0;
$user->active = 1;
$user->authinstance = $authinstance->id;
$user->firstname = $registration->firstname;
$user->lastname = $registration->lastname;
$user->email = $registration->email;
$user->username = get_new_username($user->firstname . $user->lastname);
$user->passwordchange = 1;
$user->salt = substr(md5(rand(1000000, 9999999)), 2, 8);
create_user($user, $profilefields);
......@@ -150,6 +149,7 @@ if (isset($key)) {
else {
$SESSION->add_ok_msg(get_string('registrationcomplete', 'mahara', get_config('sitename')));
}
$SESSION->set('resetusername', true);
redirect();
}
create_registered_user();
......@@ -159,30 +159,6 @@ if (isset($key)) {
// Default page - show the registration form
$elements = array(
'username' => array(
'type' => 'text',
'title' => get_string('username'),
'rules' => array(
'required' => true
),
'help' => true,
),
'password1' => array(
'type' => 'password',
'title' => get_string('password'),
'description' => get_string('passwordformdescription', 'auth.internal'),
'rules' => array(
'required' => true
),
'help' => true,
),
'password2' => array(
'type' => 'password',
'title' => get_string('confirmpassword'),
'rules' => array(
'required' => true
)
),
'firstname' => array(
'type' => 'text',
'title' => get_string('firstname'),
......@@ -297,18 +273,6 @@ function register_validate(Pieform $form, $values) {
$institution = $values['institution'];
safe_require('auth', 'internal');
if (!$form->get_error('username') && !AuthInternal::is_username_valid($values['username'])) {
$form->set_error('username', get_string('usernameinvalidform', 'auth.internal'));
}
if (!$form->get_error('username') && record_exists_select('usr', 'LOWER(username) = ?', strtolower($values['username']))) {
$form->set_error('username', get_string('usernamealreadytaken', 'auth.internal'));
}
$user =(object) $values;
$user->authinstance = get_field('auth_instance', 'id', 'authname', 'internal', 'institution', $institution);
password_validate($form, $values, $user);
// First name and last name must contain at least one non whitespace
// character, so that there's something to read
if (!$form->get_error('firstname') && !preg_match('/\S/', $values['firstname'])) {
......@@ -365,8 +329,6 @@ function register_submit(Pieform $form, $values) {
// don't die_info, since reloading the page shows the login form.
// instead, redirect to some other page that says this
safe_require('auth', 'internal');
$values['salt'] = substr(md5(rand(1000000, 9999999)), 2, 8);
$values['password'] = AuthInternal::encrypt_password($values['password1'], $values['salt']);
$values['key'] = get_random_key();
// @todo the expiry date should be configurable
$values['expiry'] = db_format_timestamp(time() + 86400);
......
{include file="header.tpl"}
{if $changepassword}
<h1>{str tag="changepassword"}</h1>
<p>{str tag="changepasswordinfo"}</p>
{if $loginasoverridepasswordchange}<div class="message">{$loginasoverridepasswordchange}</div>{/if}
{else}
<h1>{str tag='requiredfields' section='auth'}</h1>
{/if}
{$form}
{include file="footer.tpl"}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment