Sha256: 650a0659a63c03338bcfb21a685182fa738d45f6459c9ff5dc275fb10137f4a0
Contents?: true
Size: 925 Bytes
Versions: 2
Compression:
Stored size: 925 Bytes
Contents
class Logman class Auth < ConsoleBase get '/login' do erb :login, locals:{ :invalid=> false, :register=> (User.count==0) } end post '/login' do #register for the first time if User.count == 0 user = User.new(params) user.admin = true if user.save session[:user_id] = user.id.to_s return redirect '/' else return erb :login, locals:{ :invalid=> true, :register=>true } end end #login routine user = User.where(:email=>params[:email]).first if user.nil? || user.authenticate(params[:password]).blank? erb :login, locals:{ :invalid=> true, :register=>false } else session[:user_id] = user.id.to_s redirect '/' end end get '/logout' do session[:user_id] = nil redirect '/' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
logman-0.1.0 | lib/console/auth.rb |
logman-0.1.0.alpha | lib/console/auth.rb |