Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
e0db22cc
Commit
e0db22cc
authored
May 6, 2012
by
Michael Gapczynski
Browse files
Options
Downloads
Patches
Plain Diff
Provide feedback when user creation fails
parent
333345d2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/user.php
+3
-3
3 additions, 3 deletions
lib/user.php
settings/ajax/createuser.php
+4
-4
4 additions, 4 deletions
settings/ajax/createuser.php
settings/js/users.js
+3
-1
3 additions, 1 deletion
settings/js/users.js
with
10 additions
and
8 deletions
lib/user.php
+
3
−
3
View file @
e0db22cc
...
@@ -117,15 +117,15 @@ class OC_User {
...
@@ -117,15 +117,15 @@ class OC_User {
// Check the name for bad characters
// Check the name for bad characters
// Allowed are: "a-z", "A-Z", "0-9" and "_.@-"
// Allowed are: "a-z", "A-Z", "0-9" and "_.@-"
if
(
preg_match
(
'/[^a-zA-Z0-9 _\.@\-]/'
,
$uid
)){
if
(
preg_match
(
'/[^a-zA-Z0-9 _\.@\-]/'
,
$uid
)){
return
false
;
throw
new
Exception
(
'Only the following characters are allowed in a username: "a-z", "A-Z", "0-9", and "_.@-"'
)
;
}
}
// No empty username
// No empty username
if
(
trim
(
$uid
)
==
''
){
if
(
trim
(
$uid
)
==
''
){
return
false
;
throw
new
Exception
(
'A valid username must be provided'
)
;
}
}
// Check if user already exists
// Check if user already exists
if
(
self
::
userExists
(
$uid
)
){
if
(
self
::
userExists
(
$uid
)
){
return
false
;
throw
new
Exception
(
'The username is already being used'
)
;
}
}
...
...
This diff is collapsed.
Click to expand it.
settings/ajax/createuser.php
+
4
−
4
View file @
e0db22cc
...
@@ -23,7 +23,8 @@ if( in_array( $username, OC_User::getUsers())){
...
@@ -23,7 +23,8 @@ if( in_array( $username, OC_User::getUsers())){
}
}
// Return Success story
// Return Success story
if
(
OC_User
::
createUser
(
$username
,
$password
)){
try
{
OC_User
::
createUser
(
$username
,
$password
);
foreach
(
$groups
as
$i
){
foreach
(
$groups
as
$i
){
if
(
!
OC_Group
::
groupExists
(
$i
)){
if
(
!
OC_Group
::
groupExists
(
$i
)){
OC_Group
::
createGroup
(
$i
);
OC_Group
::
createGroup
(
$i
);
...
@@ -31,9 +32,8 @@ if( OC_User::createUser( $username, $password )){
...
@@ -31,9 +32,8 @@ if( OC_User::createUser( $username, $password )){
OC_Group
::
addToGroup
(
$username
,
$i
);
OC_Group
::
addToGroup
(
$username
,
$i
);
}
}
OC_JSON
::
success
(
array
(
"data"
=>
array
(
"username"
=>
$username
,
"groups"
=>
implode
(
", "
,
OC_Group
::
getUserGroups
(
$username
)))));
OC_JSON
::
success
(
array
(
"data"
=>
array
(
"username"
=>
$username
,
"groups"
=>
implode
(
", "
,
OC_Group
::
getUserGroups
(
$username
)))));
}
}
catch
(
Exception
$exception
)
{
else
{
OC_JSON
::
error
(
array
(
"data"
=>
array
(
"message"
=>
$exception
->
getMessage
())));
OC_JSON
::
error
(
array
(
"data"
=>
array
(
"message"
=>
"Unable to add user"
)));
}
}
?>
?>
This diff is collapsed.
Click to expand it.
settings/js/users.js
+
3
−
1
View file @
e0db22cc
...
@@ -158,10 +158,11 @@ $(document).ready(function(){
...
@@ -158,10 +158,11 @@ $(document).ready(function(){
event
.
preventDefault
();
event
.
preventDefault
();
var
username
=
$
(
'
#newusername
'
).
val
();
var
username
=
$
(
'
#newusername
'
).
val
();
if
(
$
(
'
#content table tbody tr
'
).
filterAttr
(
'
data-uid
'
,
username
).
length
>
0
){
if
(
$
(
'
#content table tbody tr
'
).
filterAttr
(
'
data-uid
'
,
username
).
length
>
0
){
OC
.
dialogs
.
alert
(
'
The username is already being used
'
,
'
Error creating user
'
);
return
;
return
;
}
}
if
(
$
.
trim
(
username
)
==
''
)
{
if
(
$
.
trim
(
username
)
==
''
)
{
alert
(
'
Please provide a username!
'
);
OC
.
dialogs
.
alert
(
'
A valid username must be provided
'
,
'
Error creating user
'
);
return
false
;
return
false
;
}
}
var
password
=
$
(
'
#newuserpassword
'
).
val
();
var
password
=
$
(
'
#newuserpassword
'
).
val
();
...
@@ -177,6 +178,7 @@ $(document).ready(function(){
...
@@ -177,6 +178,7 @@ $(document).ready(function(){
function
(
result
){
function
(
result
){
if
(
result
.
status
!=
'
success
'
){
if
(
result
.
status
!=
'
success
'
){
tr
.
remove
();
tr
.
remove
();
OC
.
dialogs
.
alert
(
result
.
data
.
message
,
'
Error creating user
'
);
}
}
}
}
);
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment