webdap/app/controllers/auth.rb

27 lines
581 B
Ruby
Raw Normal View History

2022-12-10 01:59:30 -05:00
class AuthController < Sinatra::Base
get '/login' do
erb :'auth/login', :locals => {
:title => 'Login to your account'
}
end
2022-12-10 18:55:58 -05:00
post '/login' do
ldap = Net::LDAP.new
ldap.host = cnf['ldap']['server_url']
ldap.port = 389
ldap.auth(params[:login_username], params[:login_password])
if ldap.bind()
session['ldap_uid'] = params[:username]
redirect '/account/view'
else
# Authentication failure
erb :'auth/login', :locals => {
:title => 'Login to your account',
:fail => true
}
end
end
2022-12-10 01:59:30 -05:00
end