[refs #128] Add email confirmation on email change. Remove email confirmation after registration.

This commit is contained in:
konstantin.grabar 2012-03-27 17:45:09 +04:00
parent 8b31c6373f
commit f33ef75666
4 changed files with 13 additions and 1 deletions

View File

@ -16,11 +16,20 @@ class UsersController < ApplicationController
end
def update
send_confirmation = false
if params[:user][:email] != @user.email
send_confirmation = true
end
if @user.update_without_password(params[:user])
if @user.avatar && params[:delete_avatar] == '1'
@user.avatar = nil
@user.save
end
if send_confirmation
@user.confirmed_at = nil
@user.confirmation_sent_at = nil
@user.send_confirmation_instructions
end
flash[:notice] = t('flash.user.saved')
redirect_to edit_profile_path
else

View File

@ -16,6 +16,8 @@ Rosa::Application.configure do
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
#config.action_mailer.raise_delivery_errors = true
#config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp # :letter_opener
config.action_mailer.smtp_settings = { :host => "localhost", :port => 1025 }
config.action_mailer.default_url_options = { :host => 'localhost:3000' }

View File

@ -1,4 +1,4 @@
# -*- encoding : utf-8 -*-
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.

View File

@ -34,6 +34,7 @@ module Preregistration
redirect_to new_register_request_path and return unless req and resource.email == req.email
@invitation_token = req.token
resource.skip_confirmation!
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?