Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/auth/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const profile = require('npm-profile')
const log = require('../utils/log-shim')
const openUrlPrompt = require('../utils/open-url-prompt.js')
const read = require('../utils/read-user-info.js')
const replaceInfo = require('../utils/replace-info.js')

const loginPrompter = async (creds) => {
creds.username = await read.username('Username:', creds.username)
Expand All @@ -14,6 +15,10 @@ const loginPrompter = async (creds) => {
const login = async (npm, opts) => {
let res

if (opts.authType === 'legacy') {
Comment thread
wraithgar marked this conversation as resolved.
log.notice('', `Log in on ${replaceInfo(opts.registry)}`)
}

const requestOTP = async () => {
const otp = await read.otp(
'Enter one-time password: '
Expand Down
3 changes: 3 additions & 0 deletions lib/auth/sso.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const npmFetch = require('npm-registry-fetch')
const log = require('../utils/log-shim')
const openUrl = require('../utils/open-url.js')
const otplease = require('../utils/otplease.js')
const replaceInfo = require('../utils/replace-info.js')

const pollForSession = ({ registry, token, opts }) => {
log.info('adduser', 'Polling for validated SSO session')
Expand Down Expand Up @@ -39,6 +40,8 @@ const login = async (npm, { creds, registry, scope }) => {
const opts = { ...npm.flatOptions, creds, registry, scope }
const { ssoType } = opts

log.notice('', `Log in on ${replaceInfo(registry)}`)

if (!ssoType) {
throw new Error('Missing option: sso-type')
}
Expand Down
3 changes: 0 additions & 3 deletions lib/commands/adduser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const log = require('../utils/log-shim.js')
const replaceInfo = require('../utils/replace-info.js')
const BaseCommand = require('../base-command.js')
const authTypes = {
legacy: require('../auth/legacy.js'),
Expand Down Expand Up @@ -28,8 +27,6 @@ class AddUser extends BaseCommand {

log.disableProgress()

log.notice('', `Log in on ${replaceInfo(registry)}`)

const { message, newCreds } = await auth(this.npm, {
...this.npm.flatOptions,
creds,
Expand Down
9 changes: 8 additions & 1 deletion test/lib/auth/sso.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ const _flatOptions = {
const token = '24528a24f240'
const SSO_URL = 'https://registry.npmjs.org/{SSO_URL}'
const profile = {}
const npmFetch = {}
const npmFetch = {
cleanUrl: (s) => s,
}
const sso = t.mock('../../../lib/auth/sso.js', {
'proc-log': {
info: (...msgs) => {
log += msgs.join(' ') + '\n'
},
notice: (...msgs) => {
log += msgs.join(' ') + '\n'
},
},
'npm-profile': profile,
'npm-registry-fetch': npmFetch,
Expand Down Expand Up @@ -82,6 +87,7 @@ t.test('simple login', async (t) => {

t.equal(
log,
' Log in on https://registry.npmjs.org/\n' +
'adduser Polling for validated SSO session\nadduser Authorized user foo\n',
'should have correct logged info msg'
)
Expand Down Expand Up @@ -220,6 +226,7 @@ t.test('scoped login', async (t) => {

t.equal(
log,
' Log in on https://diff-registry.npmjs.org/\n' +
'adduser Polling for validated SSO session\nadduser Authorized user foo\n',
'should have correct logged info msg'
)
Expand Down