Files
danbooru/app/controllers/sessions_controller.rb
evazion 3798a2d29e logins: don't return api_token field in API.
Remove the api_token field from the response to the login action (POST
/sessions). This doesn't make sense in the presence of multiple API
keys, and is also not generally useful; if you need an API key, create
one yourself and write it down.
2021-02-15 14:28:31 -06:00

34 lines
776 B
Ruby

class SessionsController < ApplicationController
respond_to :html, :json
skip_forgery_protection only: :create, if: -> { !request.format.html? }
def new
@user = User.new
end
def confirm_password
end
def create
name, password, url = params.fetch(:session, params).slice(:name, :password, :url).values
user = SessionLoader.new(request).login(name, password)
if user
url = posts_path unless url&.start_with?("/")
respond_with(user, location: url)
else
flash.now[:notice] = "Password was incorrect"
raise SessionLoader::AuthenticationFailure
end
end
def destroy
SessionLoader.new(request).logout
redirect_to(posts_path, :notice => "You are now logged out")
end
def sign_out
destroy
end
end