metamaps--metamaps/app/controllers/api/v2/sessions_controller.rb

23 lines
448 B
Ruby
Raw Permalink Normal View History

2016-09-24 03:00:46 +00:00
# frozen_string_literal: true
2017-11-06 16:15:18 +00:00
module Api
module V2
class SessionsController < ApplicationController
def create
@user = User.find_by(email: params[:email])
2016-09-24 03:00:46 +00:00
if @user&.valid_password(params[:password])
sign_in(@user)
render json: @user
else
render json: { error: 'Error' }
end
end
def destroy
sign_out
head :no_content
end
end
end
end