require_dependency "oxen/application_controller" require "digest" module Oxen class AuthController < ApplicationController def auth unless verify_rucaptcha? flash[:alert] = "验证码出错" redirect_to login_path and return end login = params[:login] psd = params[:password] hsh_psd = Digest::SHA2.hexdigest(psd) ac = Account.where(login: login,hashed_password: hsh_psd).first if ac session[:login] = login flash[:notice] = "登录成功" redirect_to main_app.home_path and return else flash[:alert] = "登录失败" redirect_to login_path and return end end def login end def logout reset_session flash[:notice] = "成功退出" redirect_to main_app.home_path end end end