[Xfce4-commits] <moka:master> Send email to users one email and ssh account changes.
Nick Schermer
noreply at xfce.org
Sun Nov 20 14:30:35 CET 2011
Updating branch refs/heads/master
to 58b8564a64c6805b6ff0d9f090055da09706ba56 (commit)
from dd04d959304fe4c883dc29ebebd88cd5df2c79a0 (commit)
commit 58b8564a64c6805b6ff0d9f090055da09706ba56
Author: Nick Schermer <nick at xfce.org>
Date: Mon Oct 10 20:19:39 2011 +0200
Send email to users one email and ssh account changes.
TODO | 3 --
lib/controllers/authentication.rb | 4 ---
lib/controllers/maintainers.rb | 31 ++++++++++++++++++++++----
lib/views/email/login_forget.erb | 19 ++++++++-------
lib/views/email/login_request.erb | 5 +--
lib/views/email/maintainer_change_email.erb | 9 +++++++
lib/views/email/maintainer_change_ssh.erb | 9 +++++++
7 files changed, 56 insertions(+), 24 deletions(-)
diff --git a/TODO b/TODO
index 62ce641..52bd87e 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1 @@
-- Registration
-- Send verification email on email address change and ssk key change.
- Tool to generate gitolit config file and ssh key files.
-- Username checking on registration
diff --git a/lib/controllers/authentication.rb b/lib/controllers/authentication.rb
index 4d4ec95..5da50da 100755
--- a/lib/controllers/authentication.rb
+++ b/lib/controllers/authentication.rb
@@ -237,10 +237,6 @@ module Moka
@maintainer.active = false
@maintainer.save
- params[:request_url] = Moka::Models::Configuration.get(:moka_url)
- params[:request_username] = params[:username]
- params[:request_stamp] = Time.now.to_s
-
subject = "Xfce Release Manager Request: " + params[:username]
body = erb(:'email/login_request')
diff --git a/lib/controllers/maintainers.rb b/lib/controllers/maintainers.rb
index cc4e9eb..760ada6 100755
--- a/lib/controllers/maintainers.rb
+++ b/lib/controllers/maintainers.rb
@@ -27,21 +27,42 @@ module Moka
# validate the password against the authenticated user
encrypted_password = Digest::SHA1.hexdigest(params[:password])
if authentication_user.password.eql? encrypted_password
- if not params[:newpassword].empty? and validate_password(params[:newpassword], params[:newpassword2])
+ if params[:newpassword] and
+ not params[:newpassword].empty? and
+ validate_password(params[:newpassword], params[:newpassword2])
encrypted_password = Digest::SHA1.hexdigest(params[:newpassword])
@maintainer.password = encrypted_password
end
# put lines in an array and clean it up
- pubkeys = []
+ pubkeys_arr = []
params[:pubkeys].split("\n").each do |key|
key = key.strip
- pubkeys.push(key) if not key.empty? and key.start_with? "ssh-"
+ pubkeys_arr.push(key) if not key.empty? and key.start_with? "ssh-"
+ end
+ pubkeys = pubkeys_arr.join("\n")
+
+ if not @maintainer.email.to_s.eql? params[:email].to_s
+ # send mail to old address
+ Pony.mail :to => @maintainer.email,
+ :from => Moka::Models::Configuration.get(:noreply),
+ :subject => 'Release Manager Profile Change: E-mail',
+ :body => erb(:'email/maintainer_change_email')
+
+ @maintainer.email = params[:email]
+ end
+
+ if not @maintainer.pubkeys.to_s.eql? pubkeys.to_s
+ # send mail to new address
+ Pony.mail :to => @maintainer.email,
+ :from => Moka::Models::Configuration.get(:noreply),
+ :subject => 'Release Manager Profile Change: SSH',
+ :body => erb(:'email/maintainer_change_ssh')
+
+ @maintainer.pubkeys = pubkeys
end
- @maintainer.email = params[:email]
@maintainer.realname = params[:realname]
- @maintainer.pubkeys = pubkeys.join("\n")
@maintainer.save
error_set(:succeed, 'The changes to your profile have been saved.')
diff --git a/lib/views/email/login_forget.erb b/lib/views/email/login_forget.erb
index b3905db..50e4904 100644
--- a/lib/views/email/login_forget.erb
+++ b/lib/views/email/login_forget.erb
@@ -1,18 +1,19 @@
-You have (or someone impersonating you has) requested to change your
-Release manager password. To complete the change, visit the following link:
+Hello, this is Moka at <%= Moka::Models::Configuration.get(:moka_url) %>.
+
+You have (or someone impersonating you has) requested to change your release manager password. To complete the change, visit the following link:
<%= params[:token_url] %>
-If you are not the person who made this request, or you wish to cancel
-this request, visit the following link:
+If you are not the person who made this request, or you wish to cancel this request, visit the following link:
<%= params[:token_abort_url] %>
-If you do nothing, the request will lapse after 2 hours
-(<%= params[:token_expire] %>) or when you log in successfully.
+If you do nothing, the request will lapse after 2 hours (<%= params[:token_expire] %>) or when you log in successfully.
+
+The request was generated from <%= request.env['REMOTE_ADDR'] %>. Forward this email to the Xfce administrators <releases at xfce.org> in case of problems.
+
+Always at your service.
-The request was generated from <%= request.env['REMOTE_ADDR'] %>. Forward
-this email to the Xfce administrators <xfce-repo-admin at xfce.org> in
-case of problems.
+ --Moka
diff --git a/lib/views/email/login_request.erb b/lib/views/email/login_request.erb
index 68ec53a..0dc94d1 100644
--- a/lib/views/email/login_request.erb
+++ b/lib/views/email/login_request.erb
@@ -1,7 +1,6 @@
-Hello, this is Moka at <a href="<%= params[:request_url] %>"><%= params[:request_url] %></a>.
+Hello, this is Moka at <%= Moka::Models::Configuration.get(:moka_url) %>.
-The user '<%= params[:request_username] %>' has asked for access from
-<%= request.env['REMOTE_ADDR'] %> on <%= params[:request_stamp] %>.
+The user '<%= params[:username] %>' has asked for access from <%= request.env['REMOTE_ADDR'] %> on <%= Time.now.to_s %>.
Always at your service.
diff --git a/lib/views/email/maintainer_change_email.erb b/lib/views/email/maintainer_change_email.erb
new file mode 100644
index 0000000..e40e8b2
--- /dev/null
+++ b/lib/views/email/maintainer_change_email.erb
@@ -0,0 +1,9 @@
+Hello <%= @maintainer.username %>, this is Moka at <%= Moka::Models::Configuration.get(:moka_url) %>.
+
+Your e-mail address was changed from <%= @maintainer.email %> to <%= params[:email] %> from IP <%= request.env['REMOTE_ADDR'] %> on <%= Time.now.to_s %>.
+
+If you think someone else logged into your account, please forward this email to the Xfce developers at <releases at xfce.org>.
+
+Always at your service.
+
+ --Moka
diff --git a/lib/views/email/maintainer_change_ssh.erb b/lib/views/email/maintainer_change_ssh.erb
new file mode 100644
index 0000000..5c503f5
--- /dev/null
+++ b/lib/views/email/maintainer_change_ssh.erb
@@ -0,0 +1,9 @@
+Hello <%= @maintainer.username %>, this is Moka at <%= Moka::Models::Configuration.get(:moka_url) %>.
+
+Your SSH public-keys were changed from IP <%= request.env['REMOTE_ADDR'] %> on <%= Time.now.to_s %>.
+
+If you think someone else logged into your account, please forward this email to the Xfce developers at <releases at xfce.org>.
+
+Always at your service.
+
+ --Moka
More information about the Xfce4-commits
mailing list