mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:42:04 +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('login', {path: '/login'});
|
||||
this.route('login-preferences');
|
||||
this.route('forgot-password', {path: '/password-reset'});
|
||||
this.route('faq', {path: '/faq'});
|
||||
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({
|
||||
beforeModel: function() {
|
||||
this.replaceWith(this.controllerFor('application').get('loginRequired') ? 'login' : 'discovery').then(function(e) {
|
||||
Ember.run.next(function() {
|
||||
e.send('showForgotPassword');
|
||||
});
|
||||
import buildStaticRoute from 'discourse/routes/build-static-route';
|
||||
|
||||
const ForgotPasswordRoute = buildStaticRoute('password-reset');
|
||||
|
||||
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({
|
||||
beforeModel: function() {
|
||||
if (!Discourse.SiteSettings.login_required) {
|
||||
this.replaceWith('discovery.latest').then(function(e) {
|
||||
Ember.run.next(function() {
|
||||
e.send('showLogin');
|
||||
});
|
||||
import buildStaticRoute from 'discourse/routes/build-static-route';
|
||||
|
||||
const LoginRoute = buildStaticRoute('login');
|
||||
|
||||
LoginRoute.reopen({
|
||||
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?
|
||||
cookies[:destination_url] = "/my/#{params[:path]}"
|
||||
redirect_to :login
|
||||
redirect_to "/login-preferences"
|
||||
else
|
||||
redirect_to(path("/users/#{current_user.username}/#{params[:path]}"))
|
||||
end
|
||||
|
|
|
@ -807,6 +807,9 @@ en:
|
|||
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."
|
||||
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:
|
||||
title: "with Google"
|
||||
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 "privacy" => "static#show", id: "privacy", as: 'privacy'
|
||||
get "signup" => "list#latest"
|
||||
get "login-preferences" => "static#show", id: "login"
|
||||
|
||||
get "users/admin-login" => "users#admin_login"
|
||||
put "users/admin-login" => "users#admin_login"
|
||||
|
|
|
@ -1430,10 +1430,10 @@ describe UsersController 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"
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_redirect
|
||||
expect(response).to be_redirect
|
||||
end
|
||||
|
||||
context "when the user is logged in" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user