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
Boxiang Sun
gitlab-ce
Commits
442dbf6d
Commit
442dbf6d
authored
Sep 18, 2017
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
when user verifies a secondary email, revalidate GPG signatures
parent
a32f1ddd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
app/models/email.rb
app/models/email.rb
+7
-0
spec/models/email_spec.rb
spec/models/email_spec.rb
+17
-0
No files found.
app/models/email.rb
View file @
442dbf6d
...
...
@@ -7,6 +7,8 @@ class Email < ActiveRecord::Base
validates
:email
,
presence:
true
,
uniqueness:
true
,
email:
true
validate
:unique_email
,
if:
->
(
email
)
{
email
.
email_changed?
}
after_commit
:update_invalid_gpg_signatures
,
if:
->
{
previous_changes
.
key?
(
'confirmed_at'
)
}
devise
:confirmable
self
.
reconfirmable
=
false
# currently email can't be changed, no need to reconfirm
...
...
@@ -17,4 +19,9 @@ class Email < ActiveRecord::Base
def
unique_email
self
.
errors
.
add
(
:email
,
'has already been taken'
)
if
User
.
exists?
(
email:
self
.
email
)
end
# once email is confirmed, update the gpg signatures
def
update_invalid_gpg_signatures
user
.
update_invalid_gpg_signatures
if
confirmed?
end
end
spec/models/email_spec.rb
View file @
442dbf6d
...
...
@@ -11,4 +11,21 @@ describe Email do
expect
(
described_class
.
new
(
email:
' inFO@exAMPLe.com '
).
email
)
.
to
eq
'info@example.com'
end
describe
'#update_invalid_gpg_signatures'
do
let
(
:user
)
do
create
(
:user
,
email:
'tula.torphy@abshire.ca'
).
tap
do
|
user
|
user
.
skip_reconfirmation!
end
end
let
(
:user
)
{
create
(
:user
)
}
it
'synchronizes the gpg keys when the email is updated'
do
email
=
user
.
emails
.
create
(
email:
'new@email.com'
)
expect
(
user
).
to
receive
(
:update_invalid_gpg_signatures
)
email
.
confirm
# email.save
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