Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
47234ab3
Commit
47234ab3
authored
Nov 28, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate username. Gitlab::Regex added
parent
5ed4e7e2
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
13 deletions
+43
-13
app/models/namespace.rb
app/models/namespace.rb
+1
-1
app/models/project.rb
app/models/project.rb
+1
-1
app/models/user.rb
app/models/user.rb
+7
-4
app/views/admin/users/index.html.haml
app/views/admin/users/index.html.haml
+5
-4
app/views/admin/users/show.html.haml
app/views/admin/users/show.html.haml
+6
-0
app/views/profile/account.html.haml
app/views/profile/account.html.haml
+3
-3
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+19
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+1
-0
No files found.
app/models/namespace.rb
View file @
47234ab3
...
@@ -19,7 +19,7 @@ class Namespace < ActiveRecord::Base
...
@@ -19,7 +19,7 @@ class Namespace < ActiveRecord::Base
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:path
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
1
..
255
},
validates
:path
,
uniqueness:
true
,
presence:
true
,
length:
{
within:
1
..
255
},
format:
{
with:
/\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/
,
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:owner
,
presence:
true
validates
:owner
,
presence:
true
...
...
app/models/project.rb
View file @
47234ab3
...
@@ -59,7 +59,7 @@ class Project < ActiveRecord::Base
...
@@ -59,7 +59,7 @@ class Project < ActiveRecord::Base
validates
:description
,
length:
{
within:
0
..
2000
}
validates
:description
,
length:
{
within:
0
..
2000
}
validates
:name
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:name
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:path
,
presence:
true
,
length:
{
within:
0
..
255
},
validates
:path
,
presence:
true
,
length:
{
within:
0
..
255
},
format:
{
with:
/\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/
,
format:
{
with:
Gitlab
::
Regex
.
path_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
validates
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
...
...
app/models/user.rb
View file @
47234ab3
...
@@ -41,8 +41,8 @@ class User < ActiveRecord::Base
...
@@ -41,8 +41,8 @@ class User < ActiveRecord::Base
attr_accessible
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:bio
,
:name
,
:username
,
attr_accessible
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:bio
,
:name
,
:username
,
:skype
,
:linkedin
,
:twitter
,
:dark_scheme
,
:theme_id
,
:force_random_password
,
:skype
,
:linkedin
,
:twitter
,
:dark_scheme
,
:theme_id
,
:force_random_password
,
:extern_uid
,
:provider
,
:as
=>
[
:default
,
:admin
]
:extern_uid
,
:provider
,
as:
[
:default
,
:admin
]
attr_accessible
:projects_limit
,
:as
=>
:admin
attr_accessible
:projects_limit
,
as:
:admin
attr_accessor
:force_random_password
attr_accessor
:force_random_password
...
@@ -63,9 +63,12 @@ class User < ActiveRecord::Base
...
@@ -63,9 +63,12 @@ class User < ActiveRecord::Base
has_many
:assigned_merge_requests
,
class_name:
"MergeRequest"
,
foreign_key: :assignee_id
,
dependent: :destroy
has_many
:assigned_merge_requests
,
class_name:
"MergeRequest"
,
foreign_key: :assignee_id
,
dependent: :destroy
validates
:bio
,
length:
{
within:
0
..
255
}
validates
:bio
,
length:
{
within:
0
..
255
}
validates
:extern_uid
,
:allow_blank
=>
true
,
:uniqueness
=>
{
:scope
=>
:provider
}
validates
:extern_uid
,
allow_blank:
true
,
uniqueness:
{
scope:
:provider
}
validates
:projects_limit
,
presence:
true
,
numericality:
{
greater_than_or_equal_to:
0
}
validates
:projects_limit
,
presence:
true
,
numericality:
{
greater_than_or_equal_to:
0
}
validates
:username
,
presence:
true
validates
:username
,
presence:
true
,
uniqueness:
true
,
format:
{
with:
Gitlab
::
Regex
.
username_regex
,
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
before_validation
:generate_password
,
on: :create
before_validation
:generate_password
,
on: :create
before_save
:ensure_authentication_token
before_save
:ensure_authentication_token
...
...
app/views/admin/users/index.html.haml
View file @
47234ab3
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
=
form_tag
admin_users_path
,
method: :get
,
class:
'form-inline'
do
=
form_tag
admin_users_path
,
method: :get
,
class:
'form-inline'
do
=
text_field_tag
:name
,
params
[
:name
],
class:
"xlarge"
=
text_field_tag
:name
,
params
[
:name
],
class:
"xlarge"
=
submit_tag
"Search"
,
class:
"btn submit primary"
=
submit_tag
"Search"
,
class:
"btn submit primary"
%ul
.nav.nav-
pill
s
%ul
.nav.nav-
tab
s
%li
{
class:
"#{'active' unless params[:filter]}"
}
%li
{
class:
"#{'active' unless params[:filter]}"
}
=
link_to
"Active"
,
admin_users_path
=
link_to
"Active"
,
admin_users_path
%li
{
class:
"#{'active' if params[:filter] == "
admins
"}"
}
%li
{
class:
"#{'active' if params[:filter] == "
admins
"}"
}
...
@@ -23,24 +23,25 @@
...
@@ -23,24 +23,25 @@
%thead
%thead
%th
Admin
%th
Admin
%th
Name
%th
Name
%th
Username
%th
Email
%th
Email
%th
Projects
%th
Projects
%th
Edit
%th
Edit
%th
Blocked
%th
.cred
Danger Zone!
%th
.cred
Danger Zone!
-
@admin_users
.
each
do
|
user
|
-
@admin_users
.
each
do
|
user
|
%tr
%tr
%td
=
check_box_tag
"admin"
,
1
,
user
.
admin
,
disabled: :disabled
%td
=
check_box_tag
"admin"
,
1
,
user
.
admin
,
disabled: :disabled
%td
=
link_to
user
.
name
,
[
:admin
,
user
]
%td
=
link_to
user
.
name
,
[
:admin
,
user
]
%td
=
user
.
username
%td
=
user
.
email
%td
=
user
.
email
%td
=
user
.
users_projects
.
count
%td
=
user
.
users_projects
.
count
%td
=
link_to
'Edit'
,
edit_admin_user_path
(
user
),
id:
"edit_
#{
dom_id
(
user
)
}
"
,
class:
"btn small"
%td
=
link_to
'Edit'
,
edit_admin_user_path
(
user
),
id:
"edit_
#{
dom_id
(
user
)
}
"
,
class:
"btn small"
%td
%td
.bgred
-
if
user
.
blocked
-
if
user
.
blocked
=
link_to
'Unblock'
,
unblock_admin_user_path
(
user
),
method: :put
,
class:
"btn small success"
=
link_to
'Unblock'
,
unblock_admin_user_path
(
user
),
method: :put
,
class:
"btn small success"
-
else
-
else
=
link_to
'Block'
,
block_admin_user_path
(
user
),
confirm:
'USER WILL BE BLOCKED! Are you sure?'
,
method: :put
,
class:
"btn small danger"
=
link_to
'Block'
,
block_admin_user_path
(
user
),
confirm:
'USER WILL BE BLOCKED! Are you sure?'
,
method: :put
,
class:
"btn small danger"
%td
.bgred
=
link_to
'Destroy'
,
[
:admin
,
user
],
confirm:
"USER
#{
user
.
name
}
WILL BE REMOVED! Are you sure?"
,
method: :delete
,
class:
"btn small danger"
=
link_to
'Destroy'
,
[
:admin
,
user
],
confirm:
"USER
#{
user
.
name
}
WILL BE REMOVED! Are you sure?"
,
method: :delete
,
class:
"btn small danger"
=
paginate
@admin_users
,
theme:
"admin"
=
paginate
@admin_users
,
theme:
"admin"
app/views/admin/users/show.html.haml
View file @
47234ab3
...
@@ -21,6 +21,12 @@
...
@@ -21,6 +21,12 @@
Email:
Email:
%td
%td
=
@admin_user
.
email
=
@admin_user
.
email
%tr
%td
%b
Username:
%td
=
@admin_user
.
username
%tr
%tr
%td
%td
%b
%b
...
...
app/views/profile/account.html.haml
View file @
47234ab3
...
@@ -42,11 +42,11 @@
...
@@ -42,11 +42,11 @@
.clearfix
.clearfix
=
f
.
label
:password
=
f
.
label
:password
.input
=
f
.
password_field
:password
.input
=
f
.
password_field
:password
,
required:
true
.clearfix
.clearfix
=
f
.
label
:password_confirmation
=
f
.
label
:password_confirmation
.input
.input
=
f
.
password_field
:password_confirmation
=
f
.
password_field
:password_confirmation
,
required:
true
.clearfix
.clearfix
.input
.input
=
f
.
submit
'Save password'
,
class:
"btn save-btn"
=
f
.
submit
'Save password'
,
class:
"btn save-btn"
...
@@ -62,7 +62,7 @@
...
@@ -62,7 +62,7 @@
.padded
.padded
=
f
.
label
:username
=
f
.
label
:username
.input
.input
=
f
.
text_field
:username
=
f
.
text_field
:username
,
required:
true
.input
.input
=
f
.
submit
'Save username'
,
class:
"btn save-btn"
=
f
.
submit
'Save username'
,
class:
"btn save-btn"
...
...
lib/gitlab/regex.rb
0 → 100644
View file @
47234ab3
module
Gitlab
module
Regex
extend
self
def
username_regex
default_regex
end
def
path_regex
default_regex
end
protected
def
default_regex
/\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/
end
end
end
spec/models/user_spec.rb
View file @
47234ab3
...
@@ -58,6 +58,7 @@ describe User do
...
@@ -58,6 +58,7 @@ describe User do
end
end
describe
'validations'
do
describe
'validations'
do
it
{
should
validate_presence_of
(
:username
)
}
it
{
should
validate_presence_of
(
:projects_limit
)
}
it
{
should
validate_presence_of
(
:projects_limit
)
}
it
{
should
validate_numericality_of
(
:projects_limit
)
}
it
{
should
validate_numericality_of
(
:projects_limit
)
}
it
{
should
allow_value
(
0
).
for
(
:projects_limit
)
}
it
{
should
allow_value
(
0
).
for
(
:projects_limit
)
}
...
...
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