-
-
-
-
-
-`;
-/**
- * @copyright Copyright (c) 2021, Xgene Cloud Ltd
- *
- * @author Naveen MR
- * @author Pranav C Balan
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
diff --git a/packages/nocodb/src/lib/noco/meta/api/userApi/ui/auth/signup.ts b/packages/nocodb/src/lib/noco/meta/api/userApi/ui/auth/signup.ts
deleted file mode 100644
index 612a28ad3a..0000000000
--- a/packages/nocodb/src/lib/noco/meta/api/userApi/ui/auth/signup.ts
+++ /dev/null
@@ -1,135 +0,0 @@
-export default `
-
-
- NocoDB - Sign Up
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-/**
- * @copyright Copyright (c) 2021, Xgene Cloud Ltd
- *
- * @author Naveen MR
- * @author Pranav C Balan
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
diff --git a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts
index de79716be5..de03ab0cba 100644
--- a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts
+++ b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts
@@ -269,8 +269,8 @@ async function passwordForgot(req: Request, res): Promise {
}
const email = _email.toLowerCase();
-
const user = await User.getByEmail(email);
+
if (user) {
const token = uuidv4();
await User.update(user.id, {
@@ -286,15 +286,16 @@ async function passwordForgot(req: Request, res): Promise {
subject: 'Password Reset Link',
text: `Visit following link to update your password : ${
(req as any).ncSiteUrl
- }/password/reset/${token}.`,
+ }/api/v1/db/auth/password/reset/${token}.`,
html: ejs.render(template, {
- resetLink: (req as any).ncSiteUrl + `/password/reset/${token}`
+ resetLink: (req as any).ncSiteUrl + `/api/v1/db/auth/password/reset/${token}`
})
})
);
} catch (e) {
- console.log(
- 'Warning : `mailSend` failed, Please configure emailClient configuration.'
+ console.log(e)
+ return NcError.badRequest(
+ 'Email Plugin is not found. Please contact administrators to configure it in App Store first.'
);
}
@@ -305,12 +306,16 @@ async function passwordForgot(req: Request, res): Promise {
description: `requested for password reset `,
ip: (req as any).clientIp
});
+ } else {
+ return NcError.badRequest(
+ 'Your email has not been registered.'
+ );
}
- res.json({ msg: 'Check your email if you are registered with us.' });
+ res.json({ msg: 'Please check your email to reset the password' });
}
async function tokenValidate(req, res): Promise {
- const token = req.params.token;
+ const token = req.params.tokenId;
const user = await Noco.ncMeta.metaGet(null, null, MetaTable.USERS, {
reset_password_token: token
@@ -326,7 +331,7 @@ async function tokenValidate(req, res): Promise {
}
async function passwordReset(req, res): Promise {
- const token = req.params.token;
+ const token = req.params.tokenId;
const user = await Noco.ncMeta.metaGet(null, null, MetaTable.USERS, {
reset_password_token: token
@@ -364,7 +369,7 @@ async function passwordReset(req, res): Promise {
}
async function emailVerification(req, res): Promise {
- const token = req.params.token;
+ const token = req.params.tokenId;
const user = await Noco.ncMeta.metaGet(null, null, MetaTable.USERS, {
email_verification_token: token
@@ -428,6 +433,19 @@ async function refreshToken(req, res): Promise {
}
}
+async function renderPasswordReset(req, res): Promise {
+ try {
+ res.send(
+ ejs.render((await import('./ui/auth/resetPassword')).default, {
+ token: JSON.stringify(req.params.tokenId),
+ baseUrl: `/`
+ })
+ );
+ } catch (e) {
+ return res.status(400).json({ msg: e.message });
+ }
+}
+
const mapRoutes = router => {
// todo: old api - /auth/signup?tool=1
router.post('/auth/user/signup', catchError(signup));
@@ -472,5 +490,9 @@ const mapRoutes = router => {
'/api/v1/db/auth/token/refresh',
ncMetaAclMw(refreshToken, 'refreshToken')
);
+ router.get(
+ '/api/v1/db/auth/password/reset/:tokenId',
+ catchError(renderPasswordReset)
+ );
};
export { mapRoutes as userApis };