move dashboard setting into dashboard.js
This commit is contained in:
15
src/users.js
15
src/users.js
@@ -78,6 +78,7 @@ const appPasswords = require('./apppasswords.js'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
crypto = require('crypto'),
|
||||
constants = require('./constants.js'),
|
||||
dashboard = require('./dashboard.js'),
|
||||
database = require('./database.js'),
|
||||
debug = require('debug')('box:user'),
|
||||
eventlog = require('./eventlog.js'),
|
||||
@@ -667,7 +668,8 @@ async function getPasswordResetLink(user, auditSource) {
|
||||
await update(user, { resetToken, resetTokenCreationTime }, auditSource);
|
||||
}
|
||||
|
||||
const resetLink = `https://${settings.dashboardFqdn()}/passwordreset.html?resetToken=${resetToken}`;
|
||||
const { fqdn:dashboardFqdn } = await dashboard.getLocation();
|
||||
const resetLink = `https://${dashboardFqdn}/passwordreset.html?resetToken=${resetToken}`;
|
||||
|
||||
return resetLink;
|
||||
}
|
||||
@@ -796,7 +798,8 @@ async function getInviteLink(user, auditSource) {
|
||||
if (!user.inviteToken) throw new BoxError(BoxError.BAD_STATE, 'User already used invite link');
|
||||
|
||||
const directoryConfig = await getProfileConfig();
|
||||
let inviteLink = `https://${settings.dashboardFqdn()}/setupaccount.html?inviteToken=${user.inviteToken}&email=${encodeURIComponent(user.email)}`;
|
||||
const { fqdn:dashboardFqdn } = await dashboard.getLocation();
|
||||
let inviteLink = `https://${dashboardFqdn}/setupaccount.html?inviteToken=${user.inviteToken}&email=${encodeURIComponent(user.email)}`;
|
||||
|
||||
if (user.username) inviteLink += `&username=${encodeURIComponent(user.username)}`;
|
||||
if (user.displayName) inviteLink += `&displayName=${encodeURIComponent(user.displayName)}`;
|
||||
@@ -853,7 +856,8 @@ async function setTwoFactorAuthenticationSecret(userId, auditSource) {
|
||||
|
||||
if (user.twoFactorAuthenticationEnabled) throw new BoxError(BoxError.ALREADY_EXISTS);
|
||||
|
||||
const secret = speakeasy.generateSecret({ name: `Cloudron ${settings.dashboardFqdn()} (${user.username})` });
|
||||
const { fqdn:dashboardFqdn } = await dashboard.getLocation();
|
||||
const secret = speakeasy.generateSecret({ name: `Cloudron ${dashboardFqdn} (${user.username})` });
|
||||
|
||||
await update(user, { twoFactorAuthenticationSecret: secret.base32, twoFactorAuthenticationEnabled: false }, auditSource);
|
||||
|
||||
@@ -909,13 +913,14 @@ function compareRoles(role1, role2) {
|
||||
async function getAvatarUrl(user) {
|
||||
assert.strictEqual(typeof user, 'object');
|
||||
|
||||
const fallbackUrl = `https://${settings.dashboardFqdn()}/img/avatar-default-symbolic.svg`;
|
||||
const { fqdn:dashboardFqdn } = await dashboard.getLocation();
|
||||
const fallbackUrl = `https://${dashboardFqdn}/img/avatar-default-symbolic.svg`;
|
||||
|
||||
const result = await getAvatar(user.id);
|
||||
|
||||
if (result.equals(constants.AVATAR_NONE)) return fallbackUrl;
|
||||
else if (result.equals(constants.AVATAR_GRAVATAR)) return `https://www.gravatar.com/avatar/${require('crypto').createHash('md5').update(user.email).digest('hex')}.jpg`;
|
||||
else if (result) return `https://${settings.dashboardFqdn()}/api/v1/profile/avatar/${user.id}`;
|
||||
else if (result) return `https://${dashboardFqdn}/api/v1/profile/avatar/${user.id}`;
|
||||
else return fallbackUrl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user