blob: b2de7bfbd35b55e93571425bb8cb8cf967863810 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
require 'sinatra'
require 'pp'
require 'models/user'
require 'models/log'
require '../lib/srp'
get '/' do
@user = User.current
erb :index
end
get '/signup' do
erb :signup
end
post '/signup' do
Log.clear
Log.log(:signup, params)
@user = User.current
@user.signup!(params)
redirect '/'
end
get '/login' do
@user = User.current
erb :login
end
post '/handshake/' do
@user = User.current
Log.log(:handshake, params)
@auth = @user.initialize_auth(params)
Log.log(:init_auth, @auth)
erb :handshake, :layout => false, :content_type => :xml
end
post '/authenticate/' do
@user = User.current
Log.log(:authenticate, params)
@auth = @user.authenticate(params)
Log.log(:confirm_authentication, @auth)
erb :authenticate, :layout => false, :content_type => :xml
end
get '/verify' do
erb :verify
end
helpers do
def button_link(action, options = {})
action = action.to_s
label = action.capitalize
klass = "btn btn-large"
if options.delete(:primary)
klass += " btn-primary"
label += " now..."
end
%Q(<a href="#{action}" class="#{klass}" id="#{action}-view-btn">#{label}</a>)
end
end
|