mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Skip /welcome/user page for new users
Summary: Since the new Grist sign-up page has a required field for name, we can now skip the welcome page asking for the same thing. Code and tests that can be removed later are marked with TODOs. Test Plan: Browser tests. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3266
This commit is contained in:
parent
36843e632b
commit
95592b81bd
@ -84,6 +84,7 @@ export class WelcomePage extends Disposable {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This can be removed, since the 'user' page is no longer part of any flow.
|
||||||
private _buildNameForm(owner: MultiHolder) {
|
private _buildNameForm(owner: MultiHolder) {
|
||||||
let inputEl: HTMLInputElement;
|
let inputEl: HTMLInputElement;
|
||||||
let form: HTMLFormElement;
|
let form: HTMLFormElement;
|
||||||
@ -235,6 +236,8 @@ export class WelcomePage extends Disposable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a form to ask the new user a few questions.
|
* Builds a form to ask the new user a few questions.
|
||||||
|
*
|
||||||
|
* TODO: This can be removed, since the 'info' page is no longer part of any flow.
|
||||||
*/
|
*/
|
||||||
private _buildInfoForm(owner: MultiHolder) {
|
private _buildInfoForm(owner: MultiHolder) {
|
||||||
const allFilled = Observable.create(owner, false);
|
const allFilled = Observable.create(owner, false);
|
||||||
|
@ -19,6 +19,7 @@ export type IDocPage = number | SpecialDocPage;
|
|||||||
export const HomePage = StringUnion('all', 'workspace', 'templates', 'trash');
|
export const HomePage = StringUnion('all', 'workspace', 'templates', 'trash');
|
||||||
export type IHomePage = typeof HomePage.type;
|
export type IHomePage = typeof HomePage.type;
|
||||||
|
|
||||||
|
// TODO: Remove 'user' and 'info', since those pages are no longer part of any flow.
|
||||||
export const WelcomePage = StringUnion('user', 'info', 'teams', 'signup', 'verify', 'select-account');
|
export const WelcomePage = StringUnion('user', 'info', 'teams', 'signup', 'verify', 'select-account');
|
||||||
export type WelcomePage = typeof WelcomePage.type;
|
export type WelcomePage = typeof WelcomePage.type;
|
||||||
|
|
||||||
|
@ -702,8 +702,23 @@ export class FlexServer implements GristServer {
|
|||||||
const user = getUser(req);
|
const user = getUser(req);
|
||||||
if (user && user.isFirstTimeUser) {
|
if (user && user.isFirstTimeUser) {
|
||||||
log.debug(`welcoming user: ${user.name}`);
|
log.debug(`welcoming user: ${user.name}`);
|
||||||
const prefix = isOrgInPathOnly(req.hostname) ? `/o/${mreq.org}` : '';
|
// Reset isFirstTimeUser flag.
|
||||||
return res.redirect(`${prefix}/welcome/user`);
|
await this._dbManager.updateUser(user.id, {isFirstTimeUser: false});
|
||||||
|
|
||||||
|
// This is a good time to set another flag (showNewUserQuestions), to show a popup with
|
||||||
|
// welcome question(s) to this new user. Both flags are scoped to the user, but
|
||||||
|
// isFirstTimeUser has a dedicated DB field because it predates userPrefs. Note that the
|
||||||
|
// updateOrg() method handles all levels of prefs (for user, user+org, or org).
|
||||||
|
await this._dbManager.updateOrg(getScope(req), 0, {userPrefs: {showNewUserQuestions: true}});
|
||||||
|
|
||||||
|
// Redirect to teams page if users has access to more than one org. Otherwise, redirect to
|
||||||
|
// personal org.
|
||||||
|
const domain = mreq.org;
|
||||||
|
const result = await this._dbManager.getMergedOrgs(user.id, user.id, domain || null);
|
||||||
|
const orgs = (result.status === 200) ? result.data : null;
|
||||||
|
const redirectPath = orgs && orgs.length > 1 ? '/welcome/teams' : '/';
|
||||||
|
const redirectUrl = this.getMergedOrgUrl(mreq, redirectPath);
|
||||||
|
return res.redirect(redirectUrl);
|
||||||
}
|
}
|
||||||
if (mreq.org && mreq.org.startsWith('o-')) {
|
if (mreq.org && mreq.org.startsWith('o-')) {
|
||||||
// We are on a team site without a custom subdomain.
|
// We are on a team site without a custom subdomain.
|
||||||
@ -1120,10 +1135,20 @@ export class FlexServer implements GristServer {
|
|||||||
return this._sendAppPage(req, resp, {path: 'app.html', status: 200, config: {}, googleTagManager: true});
|
return this._sendAppPage(req, resp, {path: 'app.html', status: 200, config: {}, googleTagManager: true});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Add '/welcome/teams' and '/welcome/select-account' to the above route handler,
|
||||||
|
* and remove this one, since those are the only welcome paths that are part of current UI flows.
|
||||||
|
*/
|
||||||
this.app.get('/welcome/:page', ...middleware, expressWrap(async (req, resp, next) => {
|
this.app.get('/welcome/:page', ...middleware, expressWrap(async (req, resp, next) => {
|
||||||
return this._sendAppPage(req, resp, {path: 'app.html', status: 200, config: {}, googleTagManager: true});
|
return this._sendAppPage(req, resp, {path: 'app.html', status: 200, config: {}, googleTagManager: true});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: We should now be able to remove this route, since the only remaining welcome path
|
||||||
|
* is GET /welcome/teams, and we already redirect there from the welcomeNewUser middleware.
|
||||||
|
*
|
||||||
|
* Leaving this alone for now, just in case, but we should remove this soon.
|
||||||
|
*/
|
||||||
this.app.post('/welcome/:page', ...middleware, expressWrap(async (req, resp, next) => {
|
this.app.post('/welcome/:page', ...middleware, expressWrap(async (req, resp, next) => {
|
||||||
const mreq = req as RequestWithLogin;
|
const mreq = req as RequestWithLogin;
|
||||||
const userId = getUserId(req);
|
const userId = getUserId(req);
|
||||||
@ -1131,6 +1156,9 @@ export class FlexServer implements GristServer {
|
|||||||
let redirectPath: string = '/';
|
let redirectPath: string = '/';
|
||||||
|
|
||||||
if (req.params.page === 'user') {
|
if (req.params.page === 'user') {
|
||||||
|
// The /welcome/user page is no longer part of any flow, but if visited, will still submit
|
||||||
|
// here and redirect. The full name is now part of the sign-up page, so we no longer
|
||||||
|
// need to prompt new users for their name here.
|
||||||
const name: string|undefined = req.body && req.body.username || undefined;
|
const name: string|undefined = req.body && req.body.username || undefined;
|
||||||
|
|
||||||
// Reset isFirstTimeUser flag, used to redirect a new user to the /welcome/user page.
|
// Reset isFirstTimeUser flag, used to redirect a new user to the /welcome/user page.
|
||||||
|
Loading…
Reference in New Issue
Block a user