WIP: Karol's implementation #1

Closed
stan wants to merge 23 commits from karol_master into master
12 changed files with 22 additions and 18 deletions
Showing only changes of commit dace874f4f - Show all commits

View file

@ -1,2 +1,6 @@
@import "materialize"; @import "materialize";
@import "https://fonts.googleapis.com/icon?family=Material+Icons"; @import "https://fonts.googleapis.com/icon?family=Material+Icons";
body {
margin: 100px;
}

View file

@ -18,15 +18,15 @@ class UsersController < ApplicationController
end end
def recover_password_form def recover_password_form
@recovery_code = params[:recovery_code] @recovery_password = params[:recovery_password]
@user_id = params[:id] @user_id = params[:id]
end end
def recover_password def recover_password
user = User.find(params[:user_id]) user = User.find(params[:user_id])
if user.authenticate_recovery_password(params[:recovery_code]) if user.authenticate_recovery_password(params[:recovery_password])
user.password = params[:password] user.password = params[:password]
user.password_confirmation = params[:repeated_password] user.password_confirmation = params[:password_confirmation]
user.recovery_password_digest = nil user.recovery_password_digest = nil
if user.save if user.save
redirect_to '/welcome' redirect_to '/welcome'

View file

@ -1,2 +1,2 @@
<h1>Sessions#create</h1> <h3>Sessions#create</h3>
<p>Find me in app/views/sessions/create.html.erb</p> <p>Find me in app/views/sessions/create.html.erb</p>

View file

@ -1,8 +1,9 @@
<h1>Login</h1> <h3>Login</h3>
<%= form_tag '/login' do %> <%= form_tag '/login' do %>
<%= label_tag :email%> <%= label_tag :email%>
<%= text_field_tag :email %> <%= text_field_tag :email %>
<%= label_tag :password%> <%= label_tag :password%>
<%= password_field_tag :password%> <%= password_field_tag :password%>
<%= submit_tag "Login"%> <%= submit_tag "Login"%>
<%end%> <%end%>
<%= button_to "Password recovery", '/password_recovery_request', method: :get%>

View file

@ -1,9 +1,8 @@
<h1>Welcome</h1> <h3>Welcome</h3>
<% if logged_in? %> <% if logged_in? %>
<h1>You are Logged In, <%= current_user.email %></h1> You are Logged In, <%= current_user.email %>
<%= button_to "Logout", '/logout', method: :get%> <%= button_to "Logout", '/logout', method: :get%>
<%else%> <%else%>
<%= button_to "Login", '/login', method: :get%> <%= button_to "Login", '/login', method: :get%>
<%= button_to "Sign Up", '/users/new', method: :get%> <%= button_to "Sign Up", '/users/new', method: :get%>
<%= button_to "Password recovery", '/password_recovery_request', method: :get%>
<%end%> <%end%>

View file

@ -1,2 +1,2 @@
<h1>Users#create</h1> <h3>Users#create</h3>
<p>Find me in app/views/users/create.html.erb</p> <p>Find me in app/views/users/create.html.erb</p>

View file

@ -1,4 +1,4 @@
<h1>Sign Up</h1> <h3>Sign Up</h3>
<%= form_for @user do |f|%> <%= form_for @user do |f|%>
<%= f.label :email%><br> <%= f.label :email%><br>
<%= f.text_field :email%><br> <%= f.text_field :email%><br>

View file

@ -1,9 +1,9 @@
Recover password Recover password
<%= form_with url: "/recover_password", method: :post do |form| %> <%= form_with url: "/recover_password", method: :post do |form| %>
<%= form.text_field :password %> <%= form.password_field :password %>
<%= form.text_field :repeated_password %> <%= form.password_field :password_confirmation %>
<%= form.hidden_field :recovery_code, :value => @recovery_code %> <%= form.hidden_field :recovery_password, :value => @recovery_password %>
<%= form.hidden_field :user_id, :value => @user_id %> <%= form.hidden_field :user_id, :value => @user_id %>
<%= form.submit "Change password" %> <%= form.submit "Change password" %>
<% end %> <% end %>

View file

@ -6,7 +6,7 @@ Rails.application.routes.draw do
get 'welcome', to: 'sessions#welcome' get 'welcome', to: 'sessions#welcome'
get 'password_recovery_request', to: 'users#password_recovery_request_form' get 'password_recovery_request', to: 'users#password_recovery_request_form'
post 'password_recovery_request', to: 'users#password_recovery_request' post 'password_recovery_request', to: 'users#password_recovery_request'
get 'recover_password/:id/:recovery_code', to: 'users#recover_password_form' get 'recover_password/:id/:recovery_password', to: 'users#recover_password_form'
post 'recover_password', to: 'users#recover_password' post 'recover_password', to: 'users#recover_password'
resources :books resources :books
end end

View file

@ -58,7 +58,7 @@
<!-- This file lives in public/404.html --> <!-- This file lives in public/404.html -->
<div class="dialog"> <div class="dialog">
<div> <div>
<h1>The page you were looking for doesn't exist.</h1> <h3>The page you were looking for doesn't exist.</h3>
<p>You may have mistyped the address or the page may have moved.</p> <p>You may have mistyped the address or the page may have moved.</p>
</div> </div>
<p>If you are the application owner check the logs for more information.</p> <p>If you are the application owner check the logs for more information.</p>

View file

@ -58,7 +58,7 @@
<!-- This file lives in public/422.html --> <!-- This file lives in public/422.html -->
<div class="dialog"> <div class="dialog">
<div> <div>
<h1>The change you wanted was rejected.</h1> <h3>The change you wanted was rejected.</h3>
<p>Maybe you tried to change something you didn't have access to.</p> <p>Maybe you tried to change something you didn't have access to.</p>
</div> </div>
<p>If you are the application owner check the logs for more information.</p> <p>If you are the application owner check the logs for more information.</p>

View file

@ -58,7 +58,7 @@
<!-- This file lives in public/500.html --> <!-- This file lives in public/500.html -->
<div class="dialog"> <div class="dialog">
<div> <div>
<h1>We're sorry, but something went wrong.</h1> <h3>We're sorry, but something went wrong.</h3>
</div> </div>
<p>If you are the application owner check the logs for more information.</p> <p>If you are the application owner check the logs for more information.</p>
</div> </div>