oputil updates for AP enabled/disabled, small change to 2FA info
This commit is contained in:
parent
10e2abffc6
commit
8c609b79bb
|
@ -13,6 +13,7 @@ const getHelpFor = require('./oputil_help.js').getHelpFor;
|
||||||
const Errors = require('../enig_error.js').Errors;
|
const Errors = require('../enig_error.js').Errors;
|
||||||
const UserProps = require('../user_property.js');
|
const UserProps = require('../user_property.js');
|
||||||
|
|
||||||
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
@ -337,7 +338,9 @@ function modUserGroups(user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showUserInfo(user) {
|
function showUserInfo(user) {
|
||||||
const User = require('../../core/user.js');
|
const User = require('../user');
|
||||||
|
const ActivityPubSettings = require('../activitypub/settings');
|
||||||
|
const { OTPTypes } = require('../user_2fa_otp');
|
||||||
|
|
||||||
const statusDesc = () => {
|
const statusDesc = () => {
|
||||||
const status = user.properties[UserProps.AccountStatus];
|
const status = user.properties[UserProps.AccountStatus];
|
||||||
|
@ -362,7 +365,9 @@ function showUserInfo(user) {
|
||||||
return user.properties[UserProps.ThemeId];
|
return user.properties[UserProps.ThemeId];
|
||||||
};
|
};
|
||||||
|
|
||||||
const stdInfo = `User information:
|
const apSettings = ActivityPubSettings.fromUser(user);
|
||||||
|
|
||||||
|
let infoDump = `User information:
|
||||||
Username : ${user.username}${user.isRoot() ? ' (root/SysOp)' : ''}
|
Username : ${user.username}${user.isRoot() ? ' (root/SysOp)' : ''}
|
||||||
Real name : ${propOrNA(UserProps.RealName)}
|
Real name : ${propOrNA(UserProps.RealName)}
|
||||||
ID : ${user.userId}
|
ID : ${user.userId}
|
||||||
|
@ -374,27 +379,35 @@ Last login : ${lastLogin()}
|
||||||
Login count : ${propOrNA(UserProps.LoginCount)}
|
Login count : ${propOrNA(UserProps.LoginCount)}
|
||||||
Email : ${propOrNA(UserProps.EmailAddress)}
|
Email : ${propOrNA(UserProps.EmailAddress)}
|
||||||
Location : ${propOrNA(UserProps.Location)}
|
Location : ${propOrNA(UserProps.Location)}
|
||||||
Affiliations : ${propOrNA(UserProps.Affiliations)}`;
|
Affiliations : ${propOrNA(UserProps.Affiliations)}
|
||||||
let secInfo = '';
|
ActivityPub : ${apSettings.enabled ? 'enabled' : 'disabled'}`;
|
||||||
if (argv.security) {
|
|
||||||
const otp = user.getProperty(UserProps.AuthFactor2OTP);
|
const otp = user.getProperty(UserProps.AuthFactor2OTP);
|
||||||
if (otp) {
|
const oppDesc =
|
||||||
const backupCodesOrNa = () => {
|
{
|
||||||
try {
|
[OTPTypes.RFC6238_TOTP]: 'RFC6238 TOTP',
|
||||||
return JSON.parse(
|
[OTPTypes.RFC4266_HOTP]: 'rfc4266 HOTP',
|
||||||
user.getProperty(UserProps.AuthFactor2OTPBackupCodes)
|
[OTPTypes.GoogleAuthenticator]: 'GoogleAuth',
|
||||||
).join(', ');
|
}[otp] || 'disabled';
|
||||||
} catch (e) {
|
infoDump += `\n2FA OTP : ${oppDesc}`;
|
||||||
return 'N/A';
|
|
||||||
}
|
if (argv.security && otp) {
|
||||||
};
|
const backupCodesOrNa = () => {
|
||||||
secInfo = `\n2FA OTP : ${otp}
|
try {
|
||||||
OTP secret : ${user.getProperty(UserProps.AuthFactor2OTPSecret) || 'N/A'}
|
return JSON.parse(
|
||||||
OTP Backup : ${backupCodesOrNa()}`;
|
user.getProperty(UserProps.AuthFactor2OTPBackupCodes)
|
||||||
|
).join(', ');
|
||||||
|
} catch (e) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
infoDump += `\nOTP secret : ${
|
||||||
|
user.getProperty(UserProps.AuthFactor2OTPSecret) || 'N/A'
|
||||||
}
|
}
|
||||||
|
OTP Backup : ${backupCodesOrNa()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info(`${stdInfo}${secInfo}`);
|
console.info(infoDump);
|
||||||
}
|
}
|
||||||
|
|
||||||
function twoFactorAuthOTP(user) {
|
function twoFactorAuthOTP(user) {
|
||||||
|
|
|
@ -891,7 +891,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
||||||
_deliverNoteToSharedInbox(activity, note, cb) {
|
_deliverNoteToSharedInbox(activity, note, cb) {
|
||||||
this.log.info(
|
this.log.info(
|
||||||
{ activityId: activity.id, noteId: note.id },
|
{ activityId: activity.id, noteId: note.id },
|
||||||
'Delivering Note to Public inbox'
|
'Delivering Note to Public/Shared inbox'
|
||||||
);
|
);
|
||||||
|
|
||||||
Collection.addSharedInboxItem(activity, true, err => {
|
Collection.addSharedInboxItem(activity, true, err => {
|
||||||
|
|
Loading…
Reference in New Issue