gitlab-org--gitlab-foss/app/controllers/profiles/emails_controller.rb

36 lines
837 B
Ruby
Raw Normal View History

2015-04-30 17:06:18 +00:00
class Profiles::EmailsController < Profiles::ApplicationController
def index
@primary = current_user.email
2017-08-15 10:27:37 +00:00
@emails = current_user.emails.order_id_desc
end
def create
@email = Emails::CreateService.new(current_user, current_user, email_params).execute
2017-06-22 10:10:28 +00:00
if @email.errors.blank?
NotificationService.new.new_email(@email)
else
flash[:alert] = @email.errors.full_messages.first
end
redirect_to profile_emails_url
end
def destroy
@email = current_user.emails.find(params[:id])
2017-06-22 10:10:28 +00:00
Emails::DestroyService.new(current_user, current_user, email: @email.email).execute
respond_to do |format|
format.html { redirect_to profile_emails_url, status: 302 }
format.js { head :ok }
end
end
private
def email_params
params.require(:email).permit(:email)
end
end