rails g sessions controller in rails
Rails.application.routes.draw do
resources :sessions, only: [:create]
end
rails g sessions controller in rails
Rails.application.routes.draw do
resources :sessions, only: [:create]
end
rails g sessions controller in rails
class SessionsController < ApplicationController
def create
user = User
.find_by(email: params["user"]["email"])
.try(:authenticate, params["user"]["password"])
if user
session[:user_id] = user.id
render json: {
status: :created,
logged_in: true,
user: user
}
else
render json: { status: 401 }
end
end
end
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us