be42c05054
Enables frozen string for the following: * app/controllers/dashboard/**/*.rb * app/controllers/explore/**/*.rb * app/controllers/google_api/**/*.rb * app/controllers/groups/**/*.rb * app/controllers/import/**/*.rb * app/controllers/instance_statistics/**/*.rb * app/controllers/ldap/**/*.rb * app/controllers/oauth/**/*.rb * app/controllers/profiles/**/*.rb Partially addresses #47424.
66 lines
1.5 KiB
Ruby
66 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Profiles::ChatNamesController < Profiles::ApplicationController
|
|
before_action :chat_name_token, only: [:new]
|
|
before_action :chat_name_params, only: [:new, :create, :deny]
|
|
|
|
def index
|
|
@chat_names = current_user.chat_names
|
|
end
|
|
|
|
def new
|
|
end
|
|
|
|
def create
|
|
new_chat_name = current_user.chat_names.new(chat_name_params)
|
|
|
|
if new_chat_name.save
|
|
flash[:notice] = "Authorized #{new_chat_name.chat_name}"
|
|
else
|
|
flash[:alert] = "Could not authorize chat nickname. Try again!"
|
|
end
|
|
|
|
delete_chat_name_token
|
|
redirect_to profile_chat_names_path
|
|
end
|
|
|
|
def deny
|
|
delete_chat_name_token
|
|
|
|
flash[:notice] = "Denied authorization of chat nickname #{chat_name_params[:user_name]}."
|
|
|
|
redirect_to profile_chat_names_path
|
|
end
|
|
|
|
def destroy
|
|
@chat_name = chat_names.find(params[:id])
|
|
|
|
if @chat_name.destroy
|
|
flash[:notice] = "Deleted chat nickname: #{@chat_name.chat_name}!"
|
|
else
|
|
flash[:alert] = "Could not delete chat nickname #{@chat_name.chat_name}."
|
|
end
|
|
|
|
redirect_to profile_chat_names_path, status: :found
|
|
end
|
|
|
|
private
|
|
|
|
def delete_chat_name_token
|
|
chat_name_token.delete
|
|
end
|
|
|
|
def chat_name_params
|
|
@chat_name_params ||= chat_name_token.get || render_404
|
|
end
|
|
|
|
def chat_name_token
|
|
return render_404 unless params[:token] || render_404
|
|
|
|
@chat_name_token ||= Gitlab::ChatNameToken.new(params[:token])
|
|
end
|
|
|
|
def chat_names
|
|
@chat_names ||= current_user.chat_names
|
|
end
|
|
end
|