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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a2894b7a
Commit
a2894b7a
authored
Oct 27, 2017
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use a delegate for `username` to be more future friendly
parent
48851ff3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
app/controllers/confirmations_controller.rb
app/controllers/confirmations_controller.rb
+1
-2
app/models/email.rb
app/models/email.rb
+2
-0
spec/models/email_spec.rb
spec/models/email_spec.rb
+8
-0
No files found.
app/controllers/confirmations_controller.rb
View file @
a2894b7a
...
@@ -15,8 +15,7 @@ class ConfirmationsController < Devise::ConfirmationsController
...
@@ -15,8 +15,7 @@ class ConfirmationsController < Devise::ConfirmationsController
if
signed_in?
(
:user
)
if
signed_in?
(
:user
)
after_sign_in
(
resource
)
after_sign_in
(
resource
)
else
else
username
=
(
resource_name
==
:email
?
resource
.
user
.
username
:
resource
.
username
)
Gitlab
::
AppLogger
.
info
(
"Email Confirmed: username=
#{
resource
.
username
}
email=
#{
resource
.
email
}
ip=
#{
request
.
remote_ip
}
"
)
Gitlab
::
AppLogger
.
info
(
"Email Confirmed: username=
#{
username
}
email=
#{
resource
.
email
}
ip=
#{
request
.
remote_ip
}
"
)
flash
[
:notice
]
+=
" Please sign in."
flash
[
:notice
]
+=
" Please sign in."
new_session_path
(
:user
)
new_session_path
(
:user
)
end
end
...
...
app/models/email.rb
View file @
a2894b7a
...
@@ -14,6 +14,8 @@ class Email < ActiveRecord::Base
...
@@ -14,6 +14,8 @@ class Email < ActiveRecord::Base
devise
:confirmable
devise
:confirmable
self
.
reconfirmable
=
false
# currently email can't be changed, no need to reconfirm
self
.
reconfirmable
=
false
# currently email can't be changed, no need to reconfirm
delegate
:username
,
to: :user
def
email
=
(
value
)
def
email
=
(
value
)
write_attribute
(
:email
,
value
.
downcase
.
strip
)
write_attribute
(
:email
,
value
.
downcase
.
strip
)
end
end
...
...
spec/models/email_spec.rb
View file @
a2894b7a
...
@@ -40,4 +40,12 @@ describe Email do
...
@@ -40,4 +40,12 @@ describe Email do
expect
(
user
.
emails
.
confirmed
.
count
).
to
eq
1
expect
(
user
.
emails
.
confirmed
.
count
).
to
eq
1
end
end
end
end
describe
'delegation'
do
let
(
:user
)
{
create
(
:user
)
}
it
'delegates to :user'
do
expect
(
build
(
:email
,
user:
user
).
username
).
to
eq
user
.
username
end
end
end
end
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