Use Ember.js for the `/u/account-created` path so we can add controls
This commit is contained in:
parent
8048aeac22
commit
b381372184
|
@ -20,6 +20,8 @@ export default {
|
||||||
DiscourseURL.rewrite(new RegExp(`^/u/${username}/?$`, "i"), `/u/${username}/activity`);
|
DiscourseURL.rewrite(new RegExp(`^/u/${username}/?$`, "i"), `/u/${username}/activity`);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscourseURL.rewrite(/^\/u\/([^\/]+)\/?$/, "/u/$1/summary");
|
DiscourseURL.rewrite(/^\/u\/([^\/]+)\/?$/, "/u/$1/summary", {
|
||||||
|
exceptions: ['/u/account-created']
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,12 @@ export function rewritePath(path) {
|
||||||
const params = path.split("?");
|
const params = path.split("?");
|
||||||
|
|
||||||
let result = params[0];
|
let result = params[0];
|
||||||
rewrites.forEach(rw => result = result.replace(rw.regexp, rw.replacement));
|
rewrites.forEach(rw => {
|
||||||
|
if (((rw.opts.exceptions || []).some(ex => path.indexOf(ex) === 0))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result = result.replace(rw.regexp, rw.replacement);
|
||||||
|
});
|
||||||
|
|
||||||
if (params.length > 1) {
|
if (params.length > 1) {
|
||||||
result += `?${params[1]}`;
|
result += `?${params[1]}`;
|
||||||
|
@ -219,8 +224,8 @@ const DiscourseURL = Ember.Object.extend({
|
||||||
return this.handleURL(path, opts);
|
return this.handleURL(path, opts);
|
||||||
},
|
},
|
||||||
|
|
||||||
rewrite(regexp, replacement) {
|
rewrite(regexp, replacement, opts) {
|
||||||
rewrites.push({ regexp, replacement });
|
rewrites.push({ regexp, replacement, opts: opts || {} });
|
||||||
},
|
},
|
||||||
|
|
||||||
redirectTo(url) {
|
redirectTo(url) {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import PreloadStore from 'preload-store';
|
||||||
|
|
||||||
|
export default Ember.Route.extend({
|
||||||
|
setupController(controller) {
|
||||||
|
controller.set('accountCreated', PreloadStore.get('accountCreated'));
|
||||||
|
}
|
||||||
|
});
|
|
@ -64,6 +64,7 @@ export default function() {
|
||||||
// User routes
|
// User routes
|
||||||
this.route('users', { resetNamespace: true, path: '/u' });
|
this.route('users', { resetNamespace: true, path: '/u' });
|
||||||
this.route('password-reset', { path: '/u/password-reset/:token' });
|
this.route('password-reset', { path: '/u/password-reset/:token' });
|
||||||
|
this.route('account-created', { path: '/u/account-created' });
|
||||||
this.route('user', { path: '/u/:username', resetNamespace: true }, function() {
|
this.route('user', { path: '/u/:username', resetNamespace: true }, function() {
|
||||||
this.route('summary');
|
this.route('summary');
|
||||||
this.route('userActivity', { path: '/activity', resetNamespace: true }, function() {
|
this.route('userActivity', { path: '/activity', resetNamespace: true }, function() {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div id='simple-container'>
|
||||||
|
<div class='account-created'>{{{accountCreated.message}}}</div>
|
||||||
|
</div>
|
|
@ -7,4 +7,9 @@
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
width: 550px;
|
width: 550px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|
||||||
|
.account-created {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 24px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ require_dependency 'letter_avatar'
|
||||||
require_dependency 'distributed_cache'
|
require_dependency 'distributed_cache'
|
||||||
require_dependency 'global_path'
|
require_dependency 'global_path'
|
||||||
require_dependency 'secure_session'
|
require_dependency 'secure_session'
|
||||||
|
require_dependency 'topic_query'
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
include CurrentUser
|
include CurrentUser
|
||||||
|
|
|
@ -534,8 +534,10 @@ class UsersController < ApplicationController
|
||||||
def account_created
|
def account_created
|
||||||
@custom_body_class = "static-account-created"
|
@custom_body_class = "static-account-created"
|
||||||
@message = session['user_created_message'] || I18n.t('activation.missing_session')
|
@message = session['user_created_message'] || I18n.t('activation.missing_session')
|
||||||
|
store_preloaded("accountCreated", MultiJson.dump(message: @message))
|
||||||
|
|
||||||
expires_now
|
expires_now
|
||||||
render layout: 'no_ember'
|
render "default/empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
def activate_account
|
def activate_account
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<div id='simple-container'>
|
|
||||||
<span style="font-size: 16px; line-height: 24px;"><%= @message.html_safe %></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%- content_for(:no_ember_head) do %>
|
|
||||||
<%= render_google_universal_analytics_code %>
|
|
||||||
<%- end %>
|
|
||||||
|
|
||||||
<%= render_google_analytics_code %>
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
|
import PreloadStore from 'preload-store';
|
||||||
|
|
||||||
|
acceptance("Account Created");
|
||||||
|
|
||||||
|
test("account created", () => {
|
||||||
|
visit("/u/account-created");
|
||||||
|
PreloadStore.store('accountCreated', {
|
||||||
|
message: "Hello World"
|
||||||
|
});
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
ok(exists('.account-created'));
|
||||||
|
equal(find('.account-created').text(), "Hello World", "it displays the message");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue