Unverified Commit 5739f676 authored by Mahonri Gibson's avatar Mahonri Gibson Committed by Benjamin Neff

Save email without confirmation when podmail is disabled.

fixes #7195

closes #7455
parent a6869197
......@@ -5,6 +5,7 @@
## Bug fixes
## Features
* Change email without confirmation when mail is disabled [#7455](https://github.com/diaspora/diaspora/pull/7455)
# 0.6.6.0
......
......@@ -220,15 +220,23 @@ class UsersController < ApplicationController
end
def change_email(user_data)
@user.unconfirmed_email = user_data[:email]
if @user.save
@user.send_confirm_email
if @user.unconfirmed_email
if AppConfig.mail.enable?
@user.unconfirmed_email = user_data[:email]
if @user.save
@user.send_confirm_email
flash.now[:notice] = t("users.update.unconfirmed_email_changed")
else
@user.reload # match user object with the database
flash.now[:error] = t("users.update.unconfirmed_email_not_changed")
end
else
@user.reload # match user object with the database
flash.now[:error] = t("users.update.unconfirmed_email_not_changed")
@user.email = user_data[:email]
if @user.save
flash.now[:notice] = t("users.update.settings_updated")
else
@user.reload
flash.now[:error] = t("users.update.unconfirmed_email_not_changed")
end
end
end
......
......@@ -203,6 +203,13 @@ describe UsersController, :type => :controller do
expect(Workers::Mail::ConfirmEmail).to receive(:perform_async).with(@user.id).once
put(:update, :id => @user.id, :user => { :email => "my@newemail.com"})
end
it "saves unconfirmed_email when podmail is disabled" do
AppConfig.mail.enable = false
put(:update, id: @user.id, user: {email: "my@newemail.com"})
@user.reload
expect(@user.email).to eql("my@newemail.com")
end
end
describe 'email settings' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment