Browse Source

Alerts, fix routing

Maarten van den Berg 8 years ago
parent
commit
3cb88be0fc

+ 16 - 1
app/controllers/authentication_controller.rb

@@ -1,13 +1,28 @@
1 1
 class AuthenticationController < ApplicationController
2
+  def login_form
3
+    render layout: 'void'
4
+  end
5
+
2 6
   def login
7
+    flash[:danger] = "Not yet implemented."
8
+    redirect_to action: 'login_form'
9
+  end
10
+
11
+  def create_password_form
3 12
     render layout: 'void'
4 13
   end
5 14
 
6 15
   def create_password
16
+    flash[:danger] = "Not yet implemented."
17
+    redirect_to action: 'login'
18
+  end
19
+
20
+  def forgotten_password_form
7 21
     render layout: 'void'
8 22
   end
9 23
 
10 24
   def forgotten_password
11
-    render layout: 'void'
25
+    flash[:danger] = "Not yet implemented."
26
+    redirect_to action: 'login'
12 27
   end
13 28
 end

+ 2 - 1
app/views/authentication/create_password.html.haml

@@ -2,7 +2,8 @@
2 2
   Create password
3 3
 
4 4
 .container
5
-  = form_tag '/login', method: 'post', class: 'central-form' do
5
+  = render 'shared/alerts'
6
+  = form_tag '/register', method: 'post', class: 'central-form' do
6 7
     %h2.central-form-header.text-center
7 8
       Create password
8 9
     %p

+ 1 - 0
app/views/authentication/forgotten_password.html.haml

@@ -1,6 +1,7 @@
1 1
 - content_for :title do
2 2
   Forgot password
3 3
 .container
4
+  = render 'shared/alerts'
4 5
   = form_tag '/forgot', method: 'post', class:'central-form' do
5 6
     %h2.central-form-header.text-center
6 7
       Forgot password

+ 1 - 0
app/views/authentication/login.html.haml

@@ -2,6 +2,7 @@
2 2
   Login
3 3
 
4 4
 .container
5
+  = render 'shared/alerts'
5 6
   = form_tag("/login", method: "post", class: "central-form") do
6 7
     %h2.central-form-header.text-center
7 8
       Please sign in

+ 1 - 1
app/views/layouts/void.html.erb

@@ -1,13 +1,13 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
   <head>
4
+    <meta name="viewport" content="width=device-width, initial-scale=1">
4 5
     <title><%= yield(:title) %> | Damena</title>
5 6
     <%= csrf_meta_tags %>
6 7
 
7 8
     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8 9
     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9 10
   </head>
10
-
11 11
   <body class="void">
12 12
     <%= yield %>
13 13
   </body>

+ 4 - 0
app/views/shared/_alerts.html.haml

@@ -0,0 +1,4 @@
1
+.alerts
2
+  - flash.each do |name, msg|
3
+    %div{class: "alert alert-#{name}"}
4
+      = msg

+ 6 - 3
config/routes.rb

@@ -1,9 +1,12 @@
1 1
 Rails.application.routes.draw do
2
-  get 'login', to: 'authentication#login'
2
+  get  'login', to: 'authentication#login_form'
3
+  post 'login', to: 'authentication#login'
3 4
 
4
-  get 'authentication/create_password'
5
+  get  'register', to: 'authentication#create_password_form'
6
+  post 'register', to: 'authentication#create_password'
5 7
 
6
-  get 'authentication/forgotten_password'
8
+  get  'forgot', to: 'authentication#forgotten_password_form'
9
+  post 'forgot', to: 'authentication#forgotten_password'
7 10
 
8 11
   # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
9 12
 end