i18n sign in
This commit is contained in:
@@ -52,7 +52,8 @@ class ApplicationController < ActionController::Base
|
||||
private
|
||||
|
||||
def with_browser_locale(&)
|
||||
locale = request.env['HTTP_ACCEPT_LANGUAGE'].to_s[BROWSER_LOCALE_REGEXP].to_s
|
||||
locale = params[:lang].presence
|
||||
locale ||= request.env['HTTP_ACCEPT_LANGUAGE'].to_s[BROWSER_LOCALE_REGEXP].to_s
|
||||
|
||||
locale =
|
||||
if locale.starts_with?('en-') && locale != 'en-US'
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
class SessionsController < Devise::SessionsController
|
||||
before_action :configure_permitted_parameters
|
||||
|
||||
around_action :with_browser_locale
|
||||
|
||||
def create
|
||||
email = sign_in_params[:email].to_s.downcase
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
<div class="max-w-lg mx-auto px-2">
|
||||
<%= render 'devise/shared/select_server' if Docuseal.multitenant? %>
|
||||
<h1 class="text-4xl font-bold text-center mt-8">Sign In</h1>
|
||||
<h1 class="text-4xl font-bold text-center mt-8"><%= t('sign_in') %></h1>
|
||||
<%= form_for(resource, as: resource_name, html: { class: 'space-y-6' }, data: { turbo: params[:redir].blank? }, url: session_path(resource_name)) do |f| %>
|
||||
<% if params[:redir].present? %>
|
||||
<%= hidden_field_tag :redir, params[:redir] %>
|
||||
<% end %>
|
||||
<div class="space-y-2">
|
||||
<div class="space-y-2" dir="auto">
|
||||
<div class="form-control">
|
||||
<%= f.label :email, class: 'label' %>
|
||||
<%= f.label :email, t(:email), class: 'label' %>
|
||||
<%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'base-input' %>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<%= f.label :password, class: 'label' %>
|
||||
<%= f.label :password, t(:password), class: 'label' %>
|
||||
<%= f.password_field :password, autocomplete: 'current-password', class: 'base-input' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<%= f.button button_title(title: 'Sign In', disabled_with: 'Signing In'), class: 'base-button' %>
|
||||
<%= f.button button_title(title: t(:sign_in), disabled_with: t(:signing_in)), class: 'base-button' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if devise_mapping.omniauthable? %>
|
||||
@@ -25,14 +25,14 @@
|
||||
<%= form_for '', url: omniauth_authorize_path(resource_name, :google_oauth2), data: { turbo: false }, method: :post do |f| %>
|
||||
<set-timezone data-input-id="state" data-params="true"></set-timezone>
|
||||
<%= hidden_field_tag :state, { redir: params[:redir].to_s }.compact_blank.to_query %>
|
||||
<%= f.button button_title(title: 'Sign in with Google', icon: svg_icon('brand_google', class: 'w-6 h-6')), class: 'white-button w-full mt-4' %>
|
||||
<%= f.button button_title(title: t('sign_in_with_google'), icon: svg_icon('brand_google', class: 'w-6 h-6')), class: 'white-button w-full mt-4' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if User.omniauth_providers.include?(:microsoft_office365) %>
|
||||
<%= form_for '', url: omniauth_authorize_path(resource_name, :microsoft_office365), data: { turbo: false }, method: :post do |f| %>
|
||||
<set-timezone data-input-id="state_microsoft" data-params="true"></set-timezone>
|
||||
<%= hidden_field_tag :state, { redir: params[:redir].to_s }.compact_blank.to_query, id: 'state_microsoft' %>
|
||||
<%= f.button button_title(title: 'Sign in with Microsoft', icon: svg_icon('brand_microsoft', class: 'w-6 h-6')), class: 'white-button w-full' %>
|
||||
<%= f.button button_title(title: t('sign_in_with_microsoft'), icon: svg_icon('brand_microsoft', class: 'w-6 h-6')), class: 'white-button w-full' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
<div class="flex justify-between mt-4">
|
||||
<%- if controller_name != 'sessions' %>
|
||||
<%= link_to 'Already have an account?', new_session_path(resource_name), class: 'link link-hover mx-auto' %>
|
||||
<%= link_to t('already_have_an_account'), new_session_path(resource_name, { lang: params[:lang] }.compact_blank), class: 'link link-hover mx-auto' %>
|
||||
<% end %>
|
||||
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
||||
<%= link_to 'Create free account', registration_path({ redir: params[:redir] }.compact_blank), class: 'link link-hover' %>
|
||||
<%= link_to t('create_free_account'), registration_path({ redir: params[:redir], lang: params[:lang] }.compact_blank), class: 'link link-hover' %>
|
||||
<% end %>
|
||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
||||
<%= link_to 'Forgot your password?', new_password_path(resource_name), class: 'link link-hover' %>
|
||||
<%= link_to t('forgot_your_password_'), new_password_path(resource_name, { lang: params[:lang] }.compact_blank), class: 'link link-hover' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="text-center mt-10">
|
||||
<%= form_with url: url_for, method: :get do %>
|
||||
<% if params[:redir].present? %>
|
||||
<%= hidden_field_tag :redir, params[:redir] %>
|
||||
<% end %>
|
||||
<%= select_tag :lang, options_for_select((I18n.available_locales - %i[en pt-PT de-DE fr-FR es-ES]).map { |code| [t("language_#{code}"), code] }, I18n.locale), onchange: 'this.form.requestSubmit();', class: 'select select-sm border-base-content/30 text-base' %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="space-x-4 flex items-center">
|
||||
<% if Docuseal.demo? %>
|
||||
<a href="https://docuseal.co/sign_up" class="btn btn-neutral btn-sm btn-outline inline-flex items-center justify-center" style="height: 37px">
|
||||
Sign Up
|
||||
<%= t('sign_up') %>
|
||||
</a>
|
||||
<span class="hidden sm:inline">
|
||||
<%= render 'shared/github_button' %>
|
||||
@@ -61,18 +61,18 @@
|
||||
<% else %>
|
||||
<div class="flex space-x-2">
|
||||
<% if request.path != new_user_session_path %>
|
||||
<%= link_to new_user_session_path, class: 'font-medium text-lg' do %>
|
||||
<%= link_to new_user_session_path({ lang: params[:lang] }.compact_blank), class: 'font-medium text-lg' do %>
|
||||
<span class="flex items-center justify-center space-x-1">
|
||||
<%= svg_icon('login', class: 'w-6 h-6') %>
|
||||
<span>Sign in</span>
|
||||
<span><%= t('sign_in') %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if Docuseal.multitenant? && !request.path.in?([registration_path, new_registration_path]) %>
|
||||
<%= link_to registration_path, class: 'btn btn-neutral btn-sm btn-outline' do %>
|
||||
<%= link_to registration_path({ lang: params[:lang] }.compact_blank), class: 'btn btn-neutral btn-sm btn-outline' do %>
|
||||
<span class="flex items-center justify-center space-x-1">
|
||||
<span class="hidden sm:block">Create free Account</span>
|
||||
<span class="md:hidden">Sign Up</span>
|
||||
<span class="hidden sm:block"><%= t('create_free_account') %></span>
|
||||
<span class="md:hidden"><%= t('sign_up') %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user