summaryrefslogtreecommitdiff
path: root/src/pages/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/api')
-rw-r--r--src/pages/api/activation-request.js31
-rw-r--r--src/pages/api/activation.js16
-rw-r--r--src/pages/api/login.js3
-rw-r--r--src/pages/api/register.js3
4 files changed, 49 insertions, 4 deletions
diff --git a/src/pages/api/activation-request.js b/src/pages/api/activation-request.js
new file mode 100644
index 00000000..42ad5364
--- /dev/null
+++ b/src/pages/api/activation-request.js
@@ -0,0 +1,31 @@
+import apiOdoo from "../../helpers/apiOdoo";
+import mailer from "../../helpers/mailer";
+
+export default async function handler(req, res) {
+ try {
+ const { email } = req.body;
+ let result = await apiOdoo(
+ 'POST',
+ '/api/v1/user/activation-request',
+ {email}
+ );
+ if (result.activation_request) {
+ mailer.sendMail({
+ from: 'sales@indoteknik.com',
+ to: result.user.email,
+ subject: 'Permintaan Aktivasi Akun Indoteknik',
+ html: `
+ <h1>Permintaan Aktivasi Akun Indoteknik</h1>
+ <br>
+ <p>Aktivasi akun anda melalui link berikut: <a href="${process.env.SELF_HOST}/activate?token=${result.token}">Aktivasi Akun</a></p>
+ `
+ });
+ }
+ delete result.user;
+ delete result.token;
+ res.status(200).json(result);
+ } catch (error) {
+ console.log(error);
+ res.status(400).json({ error: error.message });
+ }
+} \ No newline at end of file
diff --git a/src/pages/api/activation.js b/src/pages/api/activation.js
new file mode 100644
index 00000000..67ec1c9e
--- /dev/null
+++ b/src/pages/api/activation.js
@@ -0,0 +1,16 @@
+import apiOdoo from "../../helpers/apiOdoo";
+
+export default async function handler(req, res) {
+ try {
+ const { token } = req.body;
+ let result = await apiOdoo(
+ 'POST',
+ '/api/v1/user/activation',
+ {token}
+ );
+ res.status(200).json(result);
+ } catch (error) {
+ console.log(error);
+ res.status(400).json({ error: error.message });
+ }
+} \ No newline at end of file
diff --git a/src/pages/api/login.js b/src/pages/api/login.js
index cf464817..a747294b 100644
--- a/src/pages/api/login.js
+++ b/src/pages/api/login.js
@@ -5,12 +5,11 @@ export default async function handler(req, res) {
const { email, password } = req.body;
let result = await apiOdoo(
'POST',
- '/api/v1/auth/login',
+ '/api/v1/user/login',
{email, password}
);
res.status(200).json(result);
} catch (error) {
- console.log(error);
res.status(400).json({ error: error.message });
}
} \ No newline at end of file
diff --git a/src/pages/api/register.js b/src/pages/api/register.js
index 5c21f5ca..323cab24 100644
--- a/src/pages/api/register.js
+++ b/src/pages/api/register.js
@@ -5,12 +5,11 @@ export default async function handler(req, res) {
const { email, name, password } = req.body;
let result = await apiOdoo(
'POST',
- '/api/v1/auth/register',
+ '/api/v1/user/register',
{email, name, password}
);
res.status(200).json(result);
} catch (error) {
- console.log(error);
res.status(400).json({ error: error.message });
}
} \ No newline at end of file