|
@@ -35,7 +35,7 @@ const saveAvatarForStatic = async (req, res, next) => {
|
|
status: 'success',
|
|
status: 'success',
|
|
code: 200,
|
|
code: 200,
|
|
data: {
|
|
data: {
|
|
- newUrl,
|
|
|
|
|
|
+ avatarUrl: newUrl,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
} catch (e) {
|
|
} catch (e) {
|
|
@@ -80,11 +80,11 @@ const logIn = async (req, res, next) => {
|
|
data: 'UNAUTHORIZED',
|
|
data: 'UNAUTHORIZED',
|
|
message: 'Invalid credentials',
|
|
message: 'Invalid credentials',
|
|
});
|
|
});
|
|
-
|
|
|
|
const id = user._id;
|
|
const id = user._id;
|
|
const payload = { id };
|
|
const payload = { id };
|
|
const token = jwt.sign(payload, SECRET_KEY, { expiresIn: '24h' });
|
|
const token = jwt.sign(payload, SECRET_KEY, { expiresIn: '24h' });
|
|
- const registration = user.name? false: true
|
|
|
|
|
|
+ let registration = false;
|
|
|
|
+ if (!user.name || !user.lastName || !user.avatarUrl) registration = true;
|
|
await UserModel.updateToken(id, token);
|
|
await UserModel.updateToken(id, token);
|
|
await UserModel.updateCode(id, '');
|
|
await UserModel.updateCode(id, '');
|
|
return res.status(200).json({
|
|
return res.status(200).json({
|
|
@@ -92,7 +92,7 @@ const logIn = async (req, res, next) => {
|
|
code: 200,
|
|
code: 200,
|
|
data: {
|
|
data: {
|
|
token,
|
|
token,
|
|
- registration
|
|
|
|
|
|
+ registration,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
} catch (e) {
|
|
} catch (e) {
|
|
@@ -147,7 +147,8 @@ const updateCredentials = async (req, res, next) => {
|
|
const user = await UserModel.updateCredentials(id, req.body);
|
|
const user = await UserModel.updateCredentials(id, req.body);
|
|
return res.status(200).json({
|
|
return res.status(200).json({
|
|
data: {
|
|
data: {
|
|
- user},
|
|
|
|
|
|
+ ...user,
|
|
|
|
+ },
|
|
});
|
|
});
|
|
} catch (e) {
|
|
} catch (e) {
|
|
next(e);
|
|
next(e);
|