Added devise login view

This commit is contained in:
Adrian Hinz 2019-05-08 17:55:37 +02:00
parent d2c13471f2
commit 4d13d81967
19 changed files with 346 additions and 29 deletions

View File

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -1,2 +1,13 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
# before_action :authenticate_user!
layout :layout_by_resource
private
def layout_by_resource
devise_controller? ? 'devise' : 'application'
end
end

View File

@ -0,0 +1,9 @@
class TestsController < ApplicationController
def index
end
def test
# u = User.create(email: 'ahinz@o2.pl', password: 'qazxsw123')
u = User.create(email: 'adhinz@gmail.com', password: 'qazxsw123')
end
end

View File

@ -0,0 +1,2 @@
module TestsHelper
end

View File

@ -1,26 +1,33 @@
<h2>Log in</h2>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
<!-- Nested Row within Card Body -->
<div class="row">
<div class="col-lg-6 d-none d-lg-block bg-login-image"></div>
<div class="col-lg-6">
<div class="p-5">
<div class="text-center">
<h1 class="h4 text-gray-900 mb-4">Witaj!</h1>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "current-password" %>
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: {class: 'user'}) do |f| %>
<div class="form-group">
<%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: 'Email', class: 'form-control form-control-user' %>
</div>
<div class="form-group">
<%= f.password_field :password, autocomplete: "current-password", placeholder: 'Hasło', class: 'form-control form-control-user' %>
</div>
<% if devise_mapping.rememberable? %>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
<div class="form-group">
<div class="custom-control custom-checkbox small">
<%= f.check_box :remember_me, class: 'custom-control-input' %>
<%= f.label :remember_me, class: 'custom-control-label' %>
</div>
</div>
<% end %>
<div class="actions">
<%= f.submit "Log in" %>
<%= f.submit t('login'), class: 'btn btn-primary btn-user btn-block' %>
<% end %>
<hr>
<%= render "devise/shared/links" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
</div>
</div>

View File

@ -1,25 +1,37 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<div class="text-center">
<%= link_to t('devise.shared.links.sign_in'), new_session_path(resource_name), class: 'small' %>
</div>
<% end %>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<div class="text-center">
<%= link_to t('devise.shared.links.sign_up'), new_registration_path(resource_name), class: 'small' %>
</div>
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<div class="text-center">
<%= link_to t('devise.shared.links.forgot_your_password'), new_password_path(resource_name), class: 'small' %>
</div>
<% end %>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<div class="text-center">
<%= link_to t('devise.shared.links.didn_t_receive_confirmation_instructions'), new_confirmation_path(resource_name), class: 'small' %>
</div>
<% end %>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<div class="text-center">
<%= link_to t('devise.shared.links.didn_t_receive_unlock_instructions'), new_unlock_path(resource_name), class: 'small' %>
</div>
<% end %>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<div class="text-center">
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), class: 'small' %>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>Kurs</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= favicon_link_tag %>
<meta name="description" content="">
<%= stylesheet_link_tag 'application', media: 'all' %>
<link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<%= javascript_include_tag 'application' %>
</head>
<body class="bg-gradient-primary">
<div class="container">
<!-- Outer Row -->
<div class="row justify-content-center">
<div class="col-xl-10 col-lg-12 col-md-9">
<div class="card o-hidden border-0 shadow-lg my-5">
<div class="card-body p-0">
<%= yield %>
</div>
</div>
</div>
</div>
</div>
<%= javascript_include_tag 'jquery.min', 'bootstrap.bundle.min' %>
<%= javascript_include_tag 'jquery.easing.min', 'sb-admin-2.min' %>
</body>
</html>

View File

@ -0,0 +1,2 @@
<h1>Tests#index</h1>
<p>Find me in app/views/tests/index.html.erb</p>

View File

@ -0,0 +1,2 @@
<h1>Tests#test</h1>
<p>Find me in app/views/tests/test.html.erb</p>

View File

@ -9,7 +9,13 @@ Bundler.require(*Rails.groups)
module CoursePlatform
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.time_zone = 'Warsaw'
config.active_record.default_timezone = :local
config.load_defaults 5.2
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**',
'*.{rb,yml}').to_s]
config.i18n.default_locale = :pl
config.encoding = 'utf-8'
config.generators.javascript_engine = :js
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers

View File

@ -36,8 +36,8 @@ Rails.application.configure do
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'akademiatechnologii.pl',
user_name: 'akademiatechnologii@gmail.com',
domain: 'akadeniatechnologii.pl',
user_name: 'akadeniatechnologii@gmail.com',
password: '12345%$#@!Adi',
authentication: 'plain',
enable_starttls_auto: true

View File

@ -0,0 +1,151 @@
pl:
activerecord:
attributes:
user:
confirmation_sent_at: Data wysłania potwierdzenia
confirmation_token: Token potwierdzający
confirmed_at: Data potwierdzenia
created_at: Data utworzenia
current_password: Aktualne hasło
current_sign_in_at: Data bieżącego logowania
current_sign_in_ip: Bieżący adres IP
email: Adres e-mail
encrypted_password: Zaszyfrowane hasło
failed_attempts: Nieudanych prób
last_sign_in_at: Data ostatniego logowania
last_sign_in_ip: Ostatni adres IP
locked_at: Data zablokowania
password: Hasło
password_confirmation: Potwierdzenie hasła
remember_created_at: Data utworzenia zapamiętania logowania
remember_me: Zapamiętaj mnie
reset_password_sent_at: Data wysłania żądania resetu hasła
reset_password_token: Token umożliwiający reset hasła
sign_in_count: Liczba logowań
unconfirmed_email: Niepotwierdzony adres e-mail
unlock_token: Token odblokowywujący
updated_at: Data uaktualnienia
models:
user:
few: Użytkowników
one: Użytkownik
other: Użytkowników
devise:
confirmations:
confirmed: Twój adres e-mail został potwierdzony.
new:
resend_confirmation_instructions: Wyślij ponownie instrukcje aktywacji
send_instructions: Instrukcja jak aktywować konto zostanie niezwłocznie wysłana na podany adres e-mail.
send_paranoid_instructions: Jeśli Twój adres e-mail istnieje w naszej bazie, w ciągu najbliższych minut otrzymasz instrukcje jak aktywować konto.
failure:
already_authenticated: Jesteś już zalogowany.
inactive: Twoje konto nie zostało jeszcze aktywowane.
invalid: Błędny adres %{authentication_keys} lub hasło.
last_attempt: Masz jeszcze jedną próbę nim Twoje konto zostanie zablokowane.
locked: Twoje konto jest zablokowane.
not_found_in_database: Błędny adres %{authentication_keys} lub hasło.
timeout: Sesja wygasła, aby kontynuować zaloguj się ponownie.
unauthenticated: Aby kontynuować zaloguj lub zarejestruj się.
unconfirmed: Aby kontynuować aktywuj konto.
mailer:
confirmation_instructions:
action: Potwierdź swoje konto
greeting: Witaj %{recipient}!
instruction: 'Możesz potwierdzić swoje konto przy pomocy poniższego linku:'
subject: Instrukcja aktywacji konta
email_changed:
greeting: Witaj %{recipient}!
message: Kontaktujemy się z Tobą, aby Cię poinformować o zmianie Twojego adresu e-mail na %{email}.
subject: E-mail zmieniony
password_change:
greeting: Witaj %{recipient}!
message: Kontaktujemy się z Tobą w celu poinformowania, że Twoje hasło zostało zmienione.
subject: Hasło zostało zmienione
reset_password_instructions:
action: Zmień swoje hasło
greeting: Cześć %{recipient}!
instruction: Ktoś zażądał zmiany hasła do Twojego konta. Hasło możesz zmienić wchodząc na poniższy link.
instruction_2: Jeśli to nie Ty zażądałeś zmiany hasła, proszę zignoruj tę wiadomość.
instruction_3: Twoje hasło nie ulegnie zmianie dopóki nie wejdziesz na poniższy link i nie ustawisz nowego.
subject: Instrukcja ustawienia nowego hasła
unlock_instructions:
action: Odblokuj swoje konto
greeting: Cześć %{recipient}!
instruction: 'Kliknij poniższy link, aby odblokować swoje konto:'
message: Twoje konto zostało zablokowane z powodu zbyt dużej liczby nieprawidłowych prób zalogowania się na nie.
subject: Instrukcja odblokowania konta
omniauth_callbacks:
failure: Logowanie przez konto %{kind} zakończyło się błędem z powodu "%{reason}".
success: Logowanie przez konto %{kind} zakończyło się pomyślnie.
passwords:
edit:
change_my_password: Zmień moje hasło
change_your_password: Zmień swoje hasło
confirm_new_password: Powtórz nowe hasło
new_password: Nowe hasło
new:
forgot_your_password: Zapomniałeś swojego hasła?
send_me_reset_password_instructions: Wyślij instrukcje zmiany hasła
no_token: Do tej strony możesz dostać się tylko poprzez wiadomość e-mail resetującą hasło. Jeśli to z niej tu trafiłeś, upewnij się, że użyłeś pełnego adresu.
send_instructions: Instrukcja zmiany hasła zostanie niezwłocznie wysłana na podany adres e-mail.
send_paranoid_instructions: Jeśli Twój adres e-mail istnieje w naszej bazie, otrzymasz zaraz wiadomość z instrukcjami odzyskiwania hasła.
updated: Hasło zmienione poprawnie. Zostałeś automatycznie zalogowany.
updated_not_active: Twoje hasło zmienione poprawnie.
registrations:
destroyed: Twoje konto zostało usunięte.
edit:
are_you_sure: Jesteś pewny?
cancel_my_account: Anuluj moje konto
currently_waiting_confirmation_for_email: 'Aktualnie oczekujemy na potwierdzenie z: %{email}'
leave_blank_if_you_don_t_want_to_change_it: pozostaw puste, jeśli nie chcesz wprowadzać zmian
title: Edytuj %{resource}
unhappy: Niezadowolony
update: Aktualizuj
we_need_your_current_password_to_confirm_your_changes: potrzebujemy Twojego bieżącego hasła, aby potwierdzić zmiany
new:
sign_up: Zarejestruj się
signed_up: Witaj! Rejestracja zakończyła się pomyślnie.
signed_up_but_inactive: Konto zostało utworzone pomyślnie. Zanim się jednak zalogujesz, musi ono zostać jeszcze aktywowane.
signed_up_but_locked: Konto zostało utworzone pomyślnie. Nie możesz się jednak zalogować, ponieważ jest ono zablokowane.
signed_up_but_unconfirmed: Wiadomość z linkiem aktywacyjnym została wysłana na podany adres e-mail. Otwórz link w celu aktywacji konta.
update_needs_confirmation: Konto zostało zaktualizowane, musimy jednak potwierdzić nowy adres e-mail. Sprawdź swoją skrzynkę pocztową i otwórz link aktywacyjny, aby ukończyć zmianę adresu.
updated: Konto zostało pomyślnie zaktualizowane.
updated_but_not_signed_in:
sessions:
already_signed_out: Wylogowano pomyślnie.
new:
sign_in: Zaloguj się
signed_in: Zalogowano pomyślnie.
signed_out: Wylogowano pomyślnie.
shared:
links:
back: Powrót
didn_t_receive_confirmation_instructions: Nie otrzymałeś instrukcji aktywacji konta?
didn_t_receive_unlock_instructions: Nie otrzymałeś instrukcji odblokowania konta?
forgot_your_password: Zapomniałeś hasła?
sign_in: Zaloguj się
sign_in_with_provider: Zaloguj się przez %{provider}
sign_up: Zarejestruj się
minimum_password_length:
few: "(minimum %{count} znaki)"
many: "(minimum %{count} znaków)"
one: "(minimum %{count} znak)"
other: "(minimum %{count} znaku)"
unlocks:
new:
resend_unlock_instructions: Wyślij instrukcje odblokowania konta
send_instructions: Wkrótce powinieneś otrzymać e-mail z instrukcjami jak odblokować swoje konto.
send_paranoid_instructions: Jeśli Twoje konto istnieje w naszej bazie, otrzymasz zaraz e-mail z instrukcjami jak odblokować swoje konto.
unlocked: Twoje konto zostało odblokowane. Zaloguj się, aby kontynuować.
errors:
messages:
already_confirmed: już został aktywowany, możesz się zalogować
confirmation_period_expired: musi być potwierdzone w ciągu %{period}, zamów nową wiadomość aktywacyjną
expired: stracił ważność, wyślij zapytanie o nowy
not_found: nie znaleziono
not_locked: nie był zablokowany
not_saved:
few: "%{resource} nie został zapisany z powodu %{count} błędów:"
many: "%{resource} nie został zapisany z powodu %{count} błędów:"
one: "%{resource} nie został zapisany z powodu jednego błędu:"
other: "%{resource} nie został zapisany z powodu %{count} błędów:"

33
config/locales/pl/pl.yml Normal file
View File

@ -0,0 +1,33 @@
pl:
logout: 'Wyloguj'
login: 'Zaloguj'
add: 'Dodaj'
actions: 'Akcje'
information: 'Informacja'
empty_list: 'Nie znaleziono żadnych elementów do wyświetlenia.'
edit: 'Edycja'
delete: 'Kasowanie'
confirm_delete: 'Czy na pewno usunąć ten element?'
phone: 'Telefon'
mobile: 'Komórkowy'
landline: 'Stacjonarny'
client: 'Klient'
email: 'Email'
city: 'Miasto'
street: 'Ulica'
nip: 'NIP'
regon: 'Regon'
www: 'Strona WWW'
full_address: 'Pełen adres'
add_cancel: 'Anuluj dodawanie'
please_wait: 'Proszę czekać...'
errors_ocurred: 'Wystąpiły następujące błędy:'
save: 'Zapisz'
login_form:
login_top: 'Zaloguj się'
login: 'Zaloguj'
email: 'Adres e-mail'
password: 'Hasło'
forgot_password: 'Zapomniane hasło?'
no_account: 'Nie masz konta?'
spikon_inv: 'Zapraszamy do Spikon!'

View File

@ -1,4 +1,6 @@
Rails.application.routes.draw do
get 'tests/index'
get 'tests/test'
namespace :admin do
resources :users
end

View File

@ -0,0 +1,19 @@
require 'rails_helper'
RSpec.describe TestsController, type: :controller do
describe "GET #index" do
it "returns http success" do
get :index
expect(response).to have_http_status(:success)
end
end
describe "GET #test" do
it "returns http success" do
get :test
expect(response).to have_http_status(:success)
end
end
end

View File

@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the TestsHelper. For example:
#
# describe TestsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe TestsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe "tests/index.html.erb", type: :view do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe "tests/test.html.erb", type: :view do
pending "add some examples to (or delete) #{__FILE__}"
end