debian-mirror-gitlab/app/controllers/profiles/emails_controller.rb

37 lines
748 B
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
class Profiles::EmailsController < Profiles::ApplicationController
2014-09-02 18:07:02 +05:30
def index
@primary = current_user.email
@emails = current_user.emails
end
def create
@email = current_user.emails.new(email_params)
2015-09-11 14:41:01 +05:30
if @email.save
NotificationService.new.new_email(@email)
else
flash[:alert] = @email.errors.full_messages.first
end
2014-09-02 18:07:02 +05:30
redirect_to profile_emails_url
end
def destroy
@email = current_user.emails.find(params[:id])
@email.destroy
2015-09-11 14:41:01 +05:30
current_user.update_secondary_emails!
2015-04-26 12:48:37 +05:30
2014-09-02 18:07:02 +05:30
respond_to do |format|
format.html { redirect_to profile_emails_url }
format.js { render nothing: true }
end
end
private
def email_params
params.require(:email).permit(:email)
end
end