5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 00:16:23 +00:00

cerrar la sesión y cambiar de idioma

This commit is contained in:
f 2018-02-26 19:08:21 -03:00
parent 194ecca5fc
commit e378ede510
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
9 changed files with 39 additions and 0 deletions

View file

@ -92,3 +92,8 @@ textarea.post-content {
direction: rtl; direction: rtl;
text-align: right; text-align: right;
} }
.btn-text {
background-color: transparent;
border: none;
}

View file

@ -1,6 +1,7 @@
# Forma de ingreso a Sutty # Forma de ingreso a Sutty
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
before_action :set_locale
# No tenemos índice de sutty, vamos directamente a ver el listado de # No tenemos índice de sutty, vamos directamente a ver el listado de
# sitios # sitios
@ -36,4 +37,8 @@ class ApplicationController < ActionController::Base
def find_lang def find_lang
params.fetch(:lang, I18n.locale.to_s) params.fetch(:lang, I18n.locale.to_s)
end end
def set_locale
I18n.locale = session[:lang] if session[:lang].present?
end
end end

View file

@ -12,10 +12,20 @@ class LoginController < ApplicationController
def create def create
authenticate authenticate
session[:lang] = params[:lang]
if authenticated? if authenticated?
# TODO enviar a la URL de donde vinimos # TODO enviar a la URL de donde vinimos
redirect_to sites_path redirect_to sites_path
else
flash[:error] = t('login.error')
render 'login/new'
end end
end end
def delete
warden.logout
redirect_to login_new_path
end
end end

View file

@ -1,5 +1,6 @@
%nav{'aria-label': 'breadcrumb', role: 'navigation'} %nav{'aria-label': 'breadcrumb', role: 'navigation'}
%ol.breadcrumb %ol.breadcrumb
%li.breadcrumb-item= render 'login/logout'
- crumbs.compact.each do |crumb| - crumbs.compact.each do |crumb|
- if crumb == crumbs.last - if crumb == crumbs.last
%li.breadcrumb-item.active{'aria-current': 'page'}= crumb %li.breadcrumb-item.active{'aria-current': 'page'}= crumb

View file

@ -0,0 +1,4 @@
= form_tag login_logout_path, method: :delete, class: 'form-inline' do
= button_tag type: 'submit', class: 'btn-text',
data: { toggle: 'tooltip' }, title: t('help.logout') do
= fa_icon('sign-out')

View file

@ -9,6 +9,10 @@
%input{type: 'email', name: 'username', class: 'form-control', placeholder: t('login.email')} %input{type: 'email', name: 'username', class: 'form-control', placeholder: t('login.email')}
.form-group .form-group
%input{type: 'password', name: 'password', class: 'form-control', placeholder: t('login.password')} %input{type: 'password', name: 'password', class: 'form-control', placeholder: t('login.password')}
.form-group
%select.form-control{name: 'lang', placeholder: t('login.lang')}
%option{value: 'en'} English
%option{value: 'es'} Castellano
.form-group .form-group
%input{type: 'submit', value: t('login.submit'), class: 'btn btn-lg btn-primary btn-block'} %input{type: 'submit', value: t('login.submit'), class: 'btn btn-lg btn-primary btn-block'}

View file

@ -3,6 +3,7 @@ en:
argument_error: 'Argument `%{argument}` must be an instance of %{class}' argument_error: 'Argument `%{argument}` must be an instance of %{class}'
unknown_locale: 'Unknown %{locale} locale' unknown_locale: 'Unknown %{locale} locale'
help: help:
logout: 'Close the session'
breadcrumbs: "What you see up here are the bread crumbs for this breadcrumbs: "What you see up here are the bread crumbs for this
site. When you enter a new section, you will see the previous ones site. When you enter a new section, you will see the previous ones
and also have a path for where you\'re standing." and also have a path for where you\'re standing."
@ -86,6 +87,9 @@ en:
email: 'E-mail' email: 'E-mail'
password: 'Password' password: 'Password'
submit: 'Log in' submit: 'Log in'
logout: 'Log out'
lang: 'Language'
error: 'There was an error during log in. Did you type your credentials correctly?'
sites: sites:
actions: 'Actions' actions: 'Actions'
posts: 'View and edit posts' posts: 'View and edit posts'

View file

@ -3,6 +3,7 @@ es:
argument_error: 'El argumento `%{argument}` debe ser una instancia de %{class}' argument_error: 'El argumento `%{argument}` debe ser una instancia de %{class}'
unknown_locale: 'El idioma %{locale} es desconocido' unknown_locale: 'El idioma %{locale} es desconocido'
help: help:
logout: 'Cierra la sesión'
breadcrumbs: 'Lo que ves arriba son las migas de pan de este sitio. breadcrumbs: 'Lo que ves arriba son las migas de pan de este sitio.
Cuando ingreses a una sección, podrás volver a las secciones Cuando ingreses a una sección, podrás volver a las secciones
anteriores y además tener una ruta de donde estás parada.' anteriores y además tener una ruta de donde estás parada.'
@ -88,6 +89,9 @@ es:
email: 'Dirección de correo' email: 'Dirección de correo'
password: 'Contraseña' password: 'Contraseña'
submit: 'Ingresar' submit: 'Ingresar'
lang: 'Idioma'
logout: 'Salir'
error: 'Hubo un error al iniciar la sesión. ¿Escribiste bien tus credenciales?'
sites: sites:
actions: 'Acciones' actions: 'Acciones'
posts: 'Ver y editar artículos' posts: 'Ver y editar artículos'

View file

@ -3,6 +3,8 @@ Rails.application.routes.draw do
get 'login/new', to: 'login#new' get 'login/new', to: 'login#new'
post 'login', to: 'login#create' post 'login', to: 'login#create'
delete 'login/logout', to: 'login#delete'
get 'markdown', to: 'application#markdown' get 'markdown', to: 'application#markdown'
resources :sites, only: [ :index, :show ] do resources :sites, only: [ :index, :show ] do