-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.body-signin { | ||
padding-top: 40px; | ||
padding-bottom: 40px; | ||
background-color: #eee; | ||
} | ||
|
||
.form-signin { | ||
max-width: 330px; | ||
padding: 15px; | ||
margin: 0 auto; | ||
} | ||
.form-signin .form-signin-heading, | ||
.form-signin .checkbox { | ||
margin-bottom: 10px; | ||
} | ||
.form-signin .checkbox { | ||
font-weight: normal; | ||
} | ||
.form-signin .form-control { | ||
position: relative; | ||
height: auto; | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
padding: 10px; | ||
font-size: 16px; | ||
} | ||
.form-signin .form-control:focus { | ||
z-index: 2; | ||
} | ||
.form-signin input[type="email"] { | ||
margin-bottom: -1px; | ||
border-bottom-right-radius: 0; | ||
border-bottom-left-radius: 0; | ||
} | ||
.form-signin input[type="password"] { | ||
margin-bottom: 10px; | ||
border-top-left-radius: 0; | ||
border-top-right-radius: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Sequel.migration do | ||
change do | ||
create_table(:users) do | ||
primary_key :id | ||
|
||
column :email, String, null: false | ||
column :password_digest, String | ||
|
||
column :created_at, DateTime, null: false | ||
column :updated_at, DateTime | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
unless env.production? | ||
DB[:communities].truncate | ||
DB[:users].truncate | ||
end | ||
|
||
|
||
Community.create name: "New Community", | ||
description: "This is a nice community" | ||
|
||
User.new(email: 'elduderino@lebowski.com', | ||
password: 'youropinionman'). | ||
save(validate: false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class User < Sequel::Model | ||
plugin :secure_password | ||
|
||
def validate | ||
super | ||
errors.add(:email, 'must be present') if !email || email.empty? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class Yogurt | ||
route 'user_sessions' do |r| | ||
r.is do | ||
r.post do | ||
env['warden'].authenticate! | ||
|
||
r.redirect session[:return_to] || '/communities' | ||
end | ||
|
||
r.delete do | ||
env['warden'].logout | ||
|
||
r.redirect '/user_sessions/new' | ||
end | ||
end | ||
|
||
r.get 'new' do | ||
render '/user_sessions/new' | ||
end | ||
|
||
r.is 'unauthenticated' do | ||
session[:return_to] = env['warden.options'][:attempted_path] | ||
response.status = 403 | ||
|
||
render '/user_sessions/new' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | ||
<meta name="description" content=""> | ||
<meta name="author" content=""> | ||
<link rel="icon" href="/public/favicon.ico"> | ||
|
||
<title>Signin Template for Bootstrap</title> | ||
|
||
<%= assets([:css, :yogurt]) %> | ||
<%= assets([:js, :yogurt]) %> | ||
|
||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> | ||
<!--[if lt IE 9]> | ||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | ||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | ||
<![endif]--> | ||
</head> | ||
|
||
<body class='body-signin'> | ||
<div class="container"> | ||
<form class="form-signin" action='/user_sessions' method='POST'> | ||
<h2 class="form-signin-heading">Please sign in</h2> | ||
<label for="email" class="sr-only">Email address</label> | ||
<input type="email" name='email' class="form-control" placeholder="Email address" required autofocus> | ||
<label for="password" class="sr-only">Password</label> | ||
<input type="password" name="password" class="form-control" placeholder="Password" required> | ||
<div class="checkbox"> | ||
<label> | ||
<input type="checkbox" value="remember-me"> Remember me | ||
</label> | ||
</div> | ||
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> | ||
</form> | ||
</div> <!-- /container --> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters