5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 19:06:20 +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;
text-align: right;
}
.btn-text {
background-color: transparent;
border: none;
}

View file

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

View file

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

View file

@ -1,5 +1,6 @@
%nav{'aria-label': 'breadcrumb', role: 'navigation'}
%ol.breadcrumb
%li.breadcrumb-item= render 'login/logout'
- crumbs.compact.each do |crumb|
- if crumb == crumbs.last
%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')}
.form-group
%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
%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}'
unknown_locale: 'Unknown %{locale} locale'
help:
logout: 'Close the session'
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
and also have a path for where you\'re standing."
@ -86,6 +87,9 @@ en:
email: 'E-mail'
password: 'Password'
submit: 'Log in'
logout: 'Log out'
lang: 'Language'
error: 'There was an error during log in. Did you type your credentials correctly?'
sites:
actions: 'Actions'
posts: 'View and edit posts'

View file

@ -3,6 +3,7 @@ es:
argument_error: 'El argumento `%{argument}` debe ser una instancia de %{class}'
unknown_locale: 'El idioma %{locale} es desconocido'
help:
logout: 'Cierra la sesión'
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
anteriores y además tener una ruta de donde estás parada.'
@ -88,6 +89,9 @@ es:
email: 'Dirección de correo'
password: 'Contraseña'
submit: 'Ingresar'
lang: 'Idioma'
logout: 'Salir'
error: 'Hubo un error al iniciar la sesión. ¿Escribiste bien tus credenciales?'
sites:
actions: 'Acciones'
posts: 'Ver y editar artículos'

View file

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