mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08:00
UX: Show a nicer "Log In" screen if the user follows /my/preferences
This commit is contained in:
parent
d66a545dd2
commit
a527c58c7d
|
@ -87,6 +87,7 @@ export default function() {
|
||||||
|
|
||||||
this.route('signup', {path: '/signup'});
|
this.route('signup', {path: '/signup'});
|
||||||
this.route('login', {path: '/login'});
|
this.route('login', {path: '/login'});
|
||||||
|
this.route('login-preferences');
|
||||||
this.route('forgot-password', {path: '/password-reset'});
|
this.route('forgot-password', {path: '/password-reset'});
|
||||||
this.route('faq', {path: '/faq'});
|
this.route('faq', {path: '/faq'});
|
||||||
this.route('tos', {path: '/tos'});
|
this.route('tos', {path: '/tos'});
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import DiscourseRoute from 'discourse/routes/discourse';
|
||||||
|
|
||||||
|
export default function(pageName) {
|
||||||
|
const route = {
|
||||||
|
model() {
|
||||||
|
return Discourse.StaticPage.find(pageName);
|
||||||
|
},
|
||||||
|
|
||||||
|
renderTemplate() {
|
||||||
|
this.render('static');
|
||||||
|
},
|
||||||
|
|
||||||
|
setupController(controller, model) {
|
||||||
|
this.controllerFor('static').set('model', model);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return DiscourseRoute.extend(route);
|
||||||
|
}
|
|
@ -1,22 +1,13 @@
|
||||||
export default Discourse.Route.extend({
|
import buildStaticRoute from 'discourse/routes/build-static-route';
|
||||||
beforeModel: function() {
|
|
||||||
this.replaceWith(this.controllerFor('application').get('loginRequired') ? 'login' : 'discovery').then(function(e) {
|
const ForgotPasswordRoute = buildStaticRoute('password-reset');
|
||||||
Ember.run.next(function() {
|
|
||||||
e.send('showForgotPassword');
|
ForgotPasswordRoute.reopen({
|
||||||
});
|
beforeModel() {
|
||||||
|
this.replaceWith(this.controllerFor('application').get('loginRequired') ? 'login' : 'discovery').then(e => {
|
||||||
|
Ember.run.next(() => e.send('showForgotPassword'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
model: function() {
|
|
||||||
return Discourse.StaticPage.find('password-reset');
|
|
||||||
},
|
|
||||||
|
|
||||||
renderTemplate: function() {
|
|
||||||
// do nothing
|
|
||||||
this.render('static');
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
|
||||||
this.controllerFor('static').set('model', model);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default ForgotPasswordRoute;
|
||||||
|
|
|
@ -1,24 +1,15 @@
|
||||||
export default Discourse.Route.extend({
|
import buildStaticRoute from 'discourse/routes/build-static-route';
|
||||||
beforeModel: function() {
|
|
||||||
if (!Discourse.SiteSettings.login_required) {
|
const LoginRoute = buildStaticRoute('login');
|
||||||
this.replaceWith('discovery.latest').then(function(e) {
|
|
||||||
Ember.run.next(function() {
|
LoginRoute.reopen({
|
||||||
e.send('showLogin');
|
beforeModel() {
|
||||||
});
|
if (!this.siteSettings.login_required) {
|
||||||
|
this.replaceWith('discovery.latest').then(e => {
|
||||||
|
Ember.run.next(() => e.send('showLogin'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
model: function() {
|
|
||||||
return Discourse.StaticPage.find('login');
|
|
||||||
},
|
|
||||||
|
|
||||||
renderTemplate: function() {
|
|
||||||
// do nothing
|
|
||||||
this.render('static');
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
|
||||||
this.controllerFor('static').set('model', model);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default LoginRoute;
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<div class='container'>
|
||||||
|
<h2>{{i18n "login.to_continue"}}</h2>
|
||||||
|
|
||||||
|
<p style='margin-top: 1em'>{{i18n "login.preferences"}}</p>
|
||||||
|
|
||||||
|
{{d-button class="btn-primary" action="showLogin" label="log_in"}}
|
||||||
|
{{d-button action="showForgotPassword" label="login.forgot"}}
|
||||||
|
</div>
|
|
@ -167,7 +167,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
if current_user.blank?
|
if current_user.blank?
|
||||||
cookies[:destination_url] = "/my/#{params[:path]}"
|
cookies[:destination_url] = "/my/#{params[:path]}"
|
||||||
redirect_to :login
|
redirect_to "/login-preferences"
|
||||||
else
|
else
|
||||||
redirect_to(path("/users/#{current_user.username}/#{params[:path]}"))
|
redirect_to(path("/users/#{current_user.username}/#{params[:path]}"))
|
||||||
end
|
end
|
||||||
|
|
|
@ -807,6 +807,9 @@ en:
|
||||||
admin_not_allowed_from_ip_address: "You can't log in as admin from that IP address."
|
admin_not_allowed_from_ip_address: "You can't log in as admin from that IP address."
|
||||||
resend_activation_email: "Click here to send the activation email again."
|
resend_activation_email: "Click here to send the activation email again."
|
||||||
sent_activation_email_again: "We sent another activation email to you at <b>{{currentEmail}}</b>. It might take a few minutes for it to arrive; be sure to check your spam folder."
|
sent_activation_email_again: "We sent another activation email to you at <b>{{currentEmail}}</b>. It might take a few minutes for it to arrive; be sure to check your spam folder."
|
||||||
|
to_continue: "Please Log In"
|
||||||
|
preferences: "You need to be logged in to change your user preferences."
|
||||||
|
forgot: "I don't recall my account details"
|
||||||
google:
|
google:
|
||||||
title: "with Google"
|
title: "with Google"
|
||||||
message: "Authenticating with Google (make sure pop up blockers are not enabled)"
|
message: "Authenticating with Google (make sure pop up blockers are not enabled)"
|
||||||
|
|
|
@ -241,6 +241,7 @@ Discourse::Application.routes.draw do
|
||||||
get "tos" => "static#show", id: "tos", as: 'tos'
|
get "tos" => "static#show", id: "tos", as: 'tos'
|
||||||
get "privacy" => "static#show", id: "privacy", as: 'privacy'
|
get "privacy" => "static#show", id: "privacy", as: 'privacy'
|
||||||
get "signup" => "list#latest"
|
get "signup" => "list#latest"
|
||||||
|
get "login-preferences" => "static#show", id: "login"
|
||||||
|
|
||||||
get "users/admin-login" => "users#admin_login"
|
get "users/admin-login" => "users#admin_login"
|
||||||
put "users/admin-login" => "users#admin_login"
|
put "users/admin-login" => "users#admin_login"
|
||||||
|
|
|
@ -1430,10 +1430,10 @@ describe UsersController do
|
||||||
|
|
||||||
describe '.my_redirect' do
|
describe '.my_redirect' do
|
||||||
|
|
||||||
it "returns 404 if the user is not logged in" do
|
it "redirects if the user is not logged in" do
|
||||||
get :my_redirect, path: "wat"
|
get :my_redirect, path: "wat"
|
||||||
expect(response).not_to be_success
|
expect(response).not_to be_success
|
||||||
expect(response).not_to be_redirect
|
expect(response).to be_redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the user is logged in" do
|
context "when the user is logged in" do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user