-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.rb
52 lines (40 loc) · 1.03 KB
/
app.rb
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
require 'sinatra'
require 'haml'
require 'authy'
require 'json'
require 'dotenv'
require_relative 'models/user'
require_relative 'helpers'
require_relative 'routes/signup'
require_relative 'routes/sessions'
require_relative 'routes/confirmation'
# Load environment configuration
Dotenv.load
# Set the environment after dotenv loads
# Default to production
environment = (ENV['APP_ENV'] || ENV['RACK_ENV'] || :production).to_sym
set :environment, environment
require 'bundler'
Bundler.require :default, environment
database_url = "sqlite3://#{Dir.pwd}/development.sqlite3"
DataMapper.setup(:default, database_url)
DataMapper.finalize
User.auto_upgrade!
module TwoFactorAuth
class App < Sinatra::Base
enable :sessions
set :root, File.dirname(__FILE__)
helpers Helpers
register Routes::Signup
register Routes::Sessions
register Routes::Confirmation
get '/' do
haml :home
end
get '/protected' do
authenticate!
@user = User.first(id: current_user)
haml :protected
end
end
end