BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
98ba075c
Unverified
Commit
98ba075c
authored
Jun 26, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User model to strong params. Comment other attr_accessible to let tests run
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
3a21c904
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
45 additions
and
44 deletions
+45
-44
users_controller.rb
app/controllers/admin/users_controller.rb
+16
-7
passwords_controller.rb
app/controllers/profiles/passwords_controller.rb
+8
-4
profiles_controller.rb
app/controllers/profiles_controller.rb
+11
-3
email.rb
app/models/email.rb
+0
-8
event.rb
app/models/event.rb
+2
-2
group.rb
app/models/group.rb
+1
-1
namespace.rb
app/models/namespace.rb
+1
-1
note.rb
app/models/note.rb
+2
-2
project_hook.rb
app/models/project_hook.rb
+1
-1
snippet.rb
app/models/snippet.rb
+1
-1
user.rb
app/models/user.rb
+0
-12
users_project.rb
app/models/users_project.rb
+1
-1
web_hook.rb
app/models/web_hook.rb
+1
-1
No files found.
app/controllers/admin/users_controller.rb
View file @
98ba075c
...
...
@@ -37,14 +37,14 @@ class Admin::UsersController < Admin::ApplicationController
end
def
create
admin
=
params
[
:user
]
.
delete
(
"admin"
)
admin
=
user_params
.
delete
(
"admin"
)
opts
=
{
force_random_password:
true
,
password_expires_at:
Time
.
now
}
@user
=
User
.
build_user
(
params
[
:user
]
.
merge
(
opts
),
as: :admin
)
@user
=
User
.
build_user
(
user_params
.
merge
(
opts
),
as: :admin
)
@user
.
admin
=
(
admin
&&
admin
.
to_i
>
0
)
@user
.
created_by_id
=
current_user
.
id
@user
.
generate_password
...
...
@@ -62,11 +62,11 @@ class Admin::UsersController < Admin::ApplicationController
end
def
update
admin
=
params
[
:user
]
.
delete
(
"admin"
)
admin
=
user_params
.
delete
(
"admin"
)
if
params
[
:user
]
[
:password
].
blank?
params
[
:user
]
.
delete
(
:password
)
params
[
:user
]
.
delete
(
:password_confirmation
)
if
user_params
[
:password
].
blank?
user_params
.
delete
(
:password
)
user_params
.
delete
(
:password_confirmation
)
end
if
admin
.
present?
...
...
@@ -74,7 +74,7 @@ class Admin::UsersController < Admin::ApplicationController
end
respond_to
do
|
format
|
if
user
.
update_attributes
(
params
[
:user
]
,
as: :admin
)
if
user
.
update_attributes
(
user_params
,
as: :admin
)
user
.
confirm!
format
.
html
{
redirect_to
[
:admin
,
user
],
notice:
'User was successfully updated.'
}
format
.
json
{
head
:ok
}
...
...
@@ -115,4 +115,13 @@ class Admin::UsersController < Admin::ApplicationController
def
user
@user
||=
User
.
find_by!
(
username:
params
[
:id
])
end
def
user_params
params
.
require
(
:user
).
permit
(
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:bio
,
:name
,
:username
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:color_scheme_id
,
:theme_id
,
:force_random_password
,
:extern_uid
,
:provider
,
:password_expires_at
,
:avatar
,
:hide_no_ssh_key
,
:projects_limit
,
:can_create_group
,
)
end
end
app/controllers/profiles/passwords_controller.rb
View file @
98ba075c
...
...
@@ -11,8 +11,8 @@ class Profiles::PasswordsController < ApplicationController
end
def
create
new_password
=
params
[
:user
]
[
:password
]
new_password_confirmation
=
params
[
:user
]
[
:password_confirmation
]
new_password
=
user_params
[
:password
]
new_password_confirmation
=
user_params
[
:password_confirmation
]
result
=
@user
.
update_attributes
(
password:
new_password
,
...
...
@@ -31,11 +31,11 @@ class Profiles::PasswordsController < ApplicationController
end
def
update
password_attributes
=
params
[
:user
]
.
select
do
|
key
,
value
|
password_attributes
=
user_params
.
select
do
|
key
,
value
|
%w(password password_confirmation)
.
include?
(
key
.
to_s
)
end
unless
@user
.
valid_password?
(
params
[
:user
]
[
:current_password
])
unless
@user
.
valid_password?
(
user_params
[
:current_password
])
redirect_to
edit_profile_password_path
,
alert:
'You must provide a valid current password'
return
end
...
...
@@ -74,4 +74,8 @@ class Profiles::PasswordsController < ApplicationController
def
authorize_change_password!
return
render_404
if
@user
.
ldap_user?
end
def
user_params
params
.
require
(
:user
).
permit
(
:password
,
:password_confirmation
)
end
end
app/controllers/profiles_controller.rb
View file @
98ba075c
...
...
@@ -14,9 +14,9 @@ class ProfilesController < ApplicationController
end
def
update
params
[
:user
]
.
delete
(
:email
)
if
@user
.
ldap_user?
user_params
.
delete
(
:email
)
if
@user
.
ldap_user?
if
@user
.
update_attributes
(
params
[
:user
]
)
if
@user
.
update_attributes
(
user_params
)
flash
[
:notice
]
=
"Profile was successfully updated"
else
flash
[
:alert
]
=
"Failed to update profile"
...
...
@@ -41,7 +41,7 @@ class ProfilesController < ApplicationController
end
def
update_username
@user
.
update_attributes
(
username:
params
[
:user
]
[
:username
])
@user
.
update_attributes
(
username:
user_params
[
:username
])
respond_to
do
|
format
|
format
.
js
...
...
@@ -57,4 +57,12 @@ class ProfilesController < ApplicationController
def
authorize_change_username!
return
render_404
unless
@user
.
can_change_username?
end
def
user_params
params
.
require
(
:user
).
permit
(
:email
,
:password
,
:password_confirmation
,
:bio
,
:name
,
:username
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:color_scheme_id
,
:theme_id
,
:avatar
,
:hide_no_ssh_key
,
)
end
end
app/models/email.rb
View file @
98ba075c
...
...
@@ -10,16 +10,8 @@
#
class
Email
<
ActiveRecord
::
Base
attr_accessible
:email
,
:user_id
#
# Relations
#
belongs_to
:user
#
# Validations
#
validates
:user_id
,
presence:
true
validates
:email
,
presence:
true
,
email:
{
strict_mode:
true
},
uniqueness:
true
validate
:unique_email
,
if:
->
(
email
)
{
email
.
email_changed?
}
...
...
app/models/event.rb
View file @
98ba075c
...
...
@@ -15,8 +15,8 @@
#
class
Event
<
ActiveRecord
::
Base
attr_accessible
:project
,
:action
,
:data
,
:author_id
,
:project_id
,
:target_id
,
:target_type
#
attr_accessible :project, :action, :data, :author_id, :project_id,
#
:target_id, :target_type
default_scope
{
where
.
not
(
author_id:
nil
)
}
...
...
app/models/group.rb
View file @
98ba075c
...
...
@@ -20,7 +20,7 @@ class Group < Namespace
has_many
:users_groups
,
dependent: :destroy
has_many
:users
,
through: :users_groups
attr_accessible
:avatar
#
attr_accessible :avatar
validate
:avatar_type
,
if:
->
(
user
)
{
user
.
avatar_changed?
}
validates
:avatar
,
file_size:
{
maximum:
100
.
kilobytes
.
to_i
}
...
...
app/models/namespace.rb
View file @
98ba075c
...
...
@@ -16,7 +16,7 @@
class
Namespace
<
ActiveRecord
::
Base
include
Gitlab
::
ShellAdapter
attr_accessible
:name
,
:description
,
:path
#
attr_accessible :name, :description, :path
has_many
:projects
,
dependent: :destroy
belongs_to
:owner
,
class_name:
"User"
...
...
app/models/note.rb
View file @
98ba075c
...
...
@@ -25,8 +25,8 @@ class Note < ActiveRecord::Base
default_value_for
:system
,
false
attr_accessible
:note
,
:noteable
,
:noteable_id
,
:noteable_type
,
:project_id
,
:attachment
,
:line_code
,
:commit_id
#
attr_accessible :note, :noteable, :noteable_id, :noteable_type, :project_id,
#
:attachment, :line_code, :commit_id
attr_mentionable
:note
belongs_to
:project
...
...
app/models/project_hook.rb
View file @
98ba075c
...
...
@@ -18,7 +18,7 @@
class
ProjectHook
<
WebHook
belongs_to
:project
attr_accessible
:push_events
,
:issues_events
,
:merge_requests_events
,
:tag_push_events
#
attr_accessible :push_events, :issues_events, :merge_requests_events, :tag_push_events
scope
:push_hooks
,
->
{
where
(
push_events:
true
)
}
scope
:tag_push_hooks
,
->
{
where
(
tag_push_events:
true
)
}
...
...
app/models/snippet.rb
View file @
98ba075c
...
...
@@ -18,7 +18,7 @@
class
Snippet
<
ActiveRecord
::
Base
include
Linguist
::
BlobHelper
attr_accessible
:title
,
:content
,
:file_name
,
:expires_at
,
:private
#
attr_accessible :title, :content, :file_name, :expires_at, :private
default_value_for
:private
,
true
...
...
app/models/user.rb
View file @
98ba075c
...
...
@@ -58,23 +58,11 @@ class User < ActiveRecord::Base
devise
:database_authenticatable
,
:token_authenticatable
,
:lockable
,
:async
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
,
:omniauthable
,
:confirmable
,
:registerable
attr_accessible
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:bio
,
:name
,
:username
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:color_scheme_id
,
:theme_id
,
:force_random_password
,
:extern_uid
,
:provider
,
:password_expires_at
,
:avatar
,
:hide_no_ssh_key
,
as:
[
:default
,
:admin
]
attr_accessible
:projects_limit
,
:can_create_group
,
as: :admin
attr_accessor
:force_random_password
# Virtual attribute for authenticating by either username or email
attr_accessor
:login
# Add login to attr_accessible
attr_accessible
:login
#
# Relations
#
...
...
app/models/users_project.rb
View file @
98ba075c
...
...
@@ -16,7 +16,7 @@ class UsersProject < ActiveRecord::Base
include
Notifiable
include
Gitlab
::
Access
attr_accessible
:user
,
:user_id
,
:project_access
#
attr_accessible :user, :user_id, :project_access
belongs_to
:user
belongs_to
:project
...
...
app/models/web_hook.rb
View file @
98ba075c
...
...
@@ -22,7 +22,7 @@ class WebHook < ActiveRecord::Base
default_value_for
:issues_events
,
false
default_value_for
:merge_requests_events
,
false
attr_accessible
:url
#
attr_accessible :url
# HTTParty timeout
default_timeout
10
...
...
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