Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
e866b4e0fab7
Unverified
Commit
e6f83399
authored
Dec 23, 2013
by
Dmitriy Zaporozhets
Browse files
Dont allow upload of non-image formats for user avatar
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
d3bdab547909
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/models/user.rb
View file @
e866b4e0
...
...
@@ -113,9 +113,8 @@ class User < ActiveRecord::Base
message:
"only letters, digits & '_' '-' '.' allowed. Letter should be first"
}
validates
:notification_level
,
inclusion:
{
in:
Notification
.
notification_levels
},
presence:
true
validate
:namespace_uniq
,
if:
->
(
user
)
{
user
.
username_changed?
}
validate
:avatar_type
,
if:
->
(
user
)
{
user
.
avatar_changed?
}
validates
:avatar
,
file_size:
{
maximum:
100
.
kilobytes
.
to_i
}
before_validation
:generate_password
,
on: :create
...
...
@@ -244,6 +243,12 @@ def namespace_uniq
end
end
def
avatar_type
unless
self
.
avatar
.
image?
self
.
errors
.
add
:avatar
,
"only images allowed"
end
end
# Groups user has access to
def
authorized_groups
@authorized_groups
||=
begin
...
...
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