mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-20 22:52:46 -05:00
Merge pull request #1432 from devnill/create-correct-user-groups
fix: fixed user creation endpoint to properly import groups
This commit is contained in:
commit
ac6c138309
1 changed files with 2 additions and 2 deletions
|
@ -23,13 +23,13 @@ export default function(route: Router, auth: IAuth, config: Config): void {
|
||||||
const remoteName = req.remote_user.name;
|
const remoteName = req.remote_user.name;
|
||||||
|
|
||||||
if (_.isNil(remoteName) === false && _.isNil(name) === false && remoteName === name) {
|
if (_.isNil(remoteName) === false && _.isNil(name) === false && remoteName === name) {
|
||||||
auth.authenticate(name, password, async function callbackAuthenticate(err, groups): Promise<void> {
|
auth.authenticate(name, password, async function callbackAuthenticate(err, user): Promise<void> {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.trace({ name, err }, 'authenticating for user @{username} failed. Error: @{err.message}');
|
logger.trace({ name, err }, 'authenticating for user @{username} failed. Error: @{err.message}');
|
||||||
return next(ErrorCode.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.BAD_USERNAME_PASSWORD));
|
return next(ErrorCode.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.BAD_USERNAME_PASSWORD));
|
||||||
}
|
}
|
||||||
|
|
||||||
const restoredRemoteUser: RemoteUser = createRemoteUser(name, groups);
|
const restoredRemoteUser: RemoteUser = createRemoteUser(name, user.groups || []);
|
||||||
const token = await getApiToken(auth, config, restoredRemoteUser, password);
|
const token = await getApiToken(auth, config, restoredRemoteUser, password);
|
||||||
|
|
||||||
res.status(HTTP_STATUS.CREATED);
|
res.status(HTTP_STATUS.CREATED);
|
||||||
|
|
Loading…
Add table
Reference in a new issue