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

36 lines
795 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
2017-09-10 17:25:29 +05:30
@email = Emails::CreateService.new(current_user, email_params).execute
2014-09-02 18:07:02 +05:30
2017-09-10 17:25:29 +05:30
if @email.errors.blank?
2015-09-11 14:41:01 +05:30
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])
2017-09-10 17:25:29 +05:30
Emails::DestroyService.new(current_user, email: @email.email).execute
2015-04-26 12:48:37 +05:30
2014-09-02 18:07:02 +05:30
respond_to do |format|
2017-09-10 17:25:29 +05:30
format.html { redirect_to profile_emails_url, status: 302 }
2016-06-02 11:05:42 +05:30
format.js { head :ok }
2014-09-02 18:07:02 +05:30
end
end
private
def email_params
params.require(:email).permit(:email)
end
end