Skip to content

Instantly share code, notes, and snippets.

@eri-b
Last active September 13, 2019 22:50
Show Gist options
  • Save eri-b/b9afaaf42645201c22f8d8e0eb034678 to your computer and use it in GitHub Desktop.
Save eri-b/b9afaaf42645201c22f8d8e0eb034678 to your computer and use it in GitHub Desktop.
class SessionsController < ApplicationController
def create
site = Site.find_by(name: params[:session][:site])
if site && site.authenticate(params[:session][:password])
session[site.name.to_sym] = "session-unlocked"
redirect_to main_path(site.name), notice: 'Logged in. Free to add/delete posts'
else
flash.now[:danger] = 'Invalid password'
redirect_to main_path(site.name), notice: 'Incorrect password'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment