Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mahara
mahara
Commits
fd9571f9
Commit
fd9571f9
authored
May 09, 2011
by
Richard Mansfield
Committed by
Gerrit Code Review
May 09, 2011
Browse files
Options
Browse Files
Download
Plain Diff
Merge "Increase length of username column to 255"
parents
da256ff0
5f1ad871
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
3 deletions
+39
-3
htdocs/auth/internal/lib.php
htdocs/auth/internal/lib.php
+30
-1
htdocs/lib/db/install.xml
htdocs/lib/db/install.xml
+1
-1
htdocs/lib/db/upgrade.php
htdocs/lib/db/upgrade.php
+7
-0
htdocs/lib/version.php
htdocs/lib/version.php
+1
-1
No files found.
htdocs/auth/internal/lib.php
View file @
fd9571f9
...
...
@@ -132,6 +132,26 @@ class AuthInternal extends Auth {
public
function
is_username_valid
(
$username
)
{
return
preg_match
(
'/^[a-zA-Z0-9!@#$%^&*()\-_=+\[{\]}\\|;:\'",<\.>\/?`]{3,30}$/'
,
$username
);
}
/**
* Internal authentication allows most standard us-keyboard-typable characters
* for username, as long as the username is between three and 236
* characters in length.
*
* This method is NOT part of the authentication API. Other authentication
* methods never have to do anything regarding usernames being validated on
* the Mahara side, so they do not need this method.
*
* This method is meant to only be called for validation by an admin of the user
* and is able to set a password longer than thirty characters in length
*
* @param string $username The username to check
* @return bool Whether the username is valid
*/
public
function
is_username_valid_admin
(
$username
)
{
return
preg_match
(
'/^[a-zA-Z0-9!@#$%^&*()\-_=+\[{\]}\\|;:\'",<\.>\/?`]{3,236}$/'
,
$username
);
}
/**
* Changes the user's username.
...
...
@@ -144,10 +164,19 @@ class AuthInternal extends Auth {
* @return string The new username, or the original username if it could not be set
*/
public
function
change_username
(
User
$user
,
$username
)
{
global
$USER
;
$this
->
must_be_ready
();
// proposed username must pass validation
if
(
$this
->
is_username_valid
(
$username
))
{
$valid
=
false
;
if
(
$USER
->
is_admin_for_user
(
$user
))
{
$valid
=
$this
->
is_username_valid_admin
(
$username
);
}
else
{
$valid
=
$this
->
is_username_valid
(
$username
);
}
if
(
$valid
)
{
$user
->
username
=
$username
;
$user
->
commit
();
}
...
...
htdocs/lib/db/install.xml
View file @
fd9571f9
...
...
@@ -76,7 +76,7 @@
<TABLE
NAME=
"usr"
>
<FIELDS>
<FIELD
NAME=
"id"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
SEQUENCE=
"true"
/>
<FIELD
NAME=
"username"
TYPE=
"char"
LENGTH=
"
100
"
NOTNULL=
"true"
/>
<FIELD
NAME=
"username"
TYPE=
"char"
LENGTH=
"
255
"
NOTNULL=
"true"
/>
<FIELD
NAME=
"password"
TYPE=
"char"
LENGTH=
"40"
NOTNULL=
"true"
/>
<FIELD
NAME=
"salt"
TYPE=
"char"
LENGTH=
"8"
/>
<FIELD
NAME=
"passwordchange"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
DEFAULT=
"0"
/>
...
...
htdocs/lib/db/upgrade.php
View file @
fd9571f9
...
...
@@ -2262,5 +2262,12 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if
(
$oldversion
<
2011050600
)
{
$table
=
new
XMLDBTable
(
'usr'
);
$field
=
new
XMLDBField
(
'username'
);
$field
->
setAttributes
(
XMLDB_TYPE_CHAR
,
255
,
null
,
XMLDB_NOTNULL
);
change_field_precision
(
$table
,
$field
);
}
return
$status
;
}
htdocs/lib/version.php
View file @
fd9571f9
...
...
@@ -28,7 +28,7 @@
defined
(
'INTERNAL'
)
||
die
();
$config
=
new
StdClass
;
$config
->
version
=
2011050
3
00
;
$config
->
version
=
2011050
6
00
;
$config
->
release
=
'1.4.0alpha2dev'
;
$config
->
minupgradefrom
=
2008040200
;
$config
->
minupgraderelease
=
'1.0.0 (release tag 1.0.0_RELEASE)'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment