-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
60 lines (46 loc) · 1.33 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
53
54
55
56
57
58
59
60
# frozen_string_literal: true
require 'sinatra/base'
require './lib/user'
require './lib/space'
# This is the route class.
class MobBoss < Sinatra::Base
enable :sessions
get '/' do
erb :index
end
get '/login' do
erb :login
end
post '/logincheck' do
session[:email_log_in] = params[:email_log_in]
session[:password_log_in] = params[:password_log_in]
# User.authenticate(email: params[:email_log_in], password: params[:password_log_in])
redirect '/logincheck'
end
get '/logincheck' do
@result = User.authenticate(email: session[:email_log_in], password: session[:password_log_in])
User.set_id_of_user if @result == true
erb :logincheck
end
get '/view_spaces' do
@spaces = Space.all
@email = Space.user
@email = Space.user_email[0]['email']
erb :view_spaces
end
get '/list_spaces' do
erb :list_spaces
end
post '/list_spaces' do
Space.list_a_space(space_name: params[:space_name], space_address: params[:space_address], space_description: params[:space_description], space_price: params[:space_price], user_id: User.user_id)
redirect '/view_spaces'
end
post '/signup' do
User.create(email: params[:email_sign_up], password: params[:password_sign_up])
redirect '/signup'
end
get '/signup' do
erb :signup
end
run! if app_file == $0
end