diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-10-30 09:53:05 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-10-30 09:53:05 +0700 |
| commit | 0831511787b1cd2171d6dd1dd6c2c9da46b64d2e (patch) | |
| tree | 46b77b2098e35e1bdadba8d46aa2ebcbe61065e3 | |
| parent | 6a87a12ca305d22db5532d1c645b67e9c5bf9747 (diff) | |
Add get activation token url on activation mail template
| -rw-r--r-- | indoteknik_api/controllers/api_v1/user.py | 5 | ||||
| -rwxr-xr-x | indoteknik_custom/models/res_users.py | 6 | ||||
| -rw-r--r-- | indoteknik_custom/views/res_users.xml | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index b64e6830..848575e2 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -124,6 +124,7 @@ class User(controller.Controller): } user = request.env['res.users'].create(user_data) + user.partner_id.email = email if company: parameter = [ @@ -192,8 +193,8 @@ class User(controller.Controller): response['reason'] = 'INVALID_TOKEN' return self.response(response) - # user.active = True - # user.activation_token = '' + user.active = True + user.activation_token = '' response.update({ 'activation': True, 'user': self.response_with_token(user) diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 02433deb..1e729550 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -27,4 +27,8 @@ class ResUsers(models.Model): for user in self: user._generate_otp() user._generate_activation_token() - template.send_mail(user.id, force_send=True)
\ No newline at end of file + template.send_mail(user.id, force_send=True) + + def get_activation_token_url(self): + base_url = self.env['ir.config_parameter'].get_param('site.base.url') + return f'{base_url}/register?activation=token&token={self.activation_token}' diff --git a/indoteknik_custom/views/res_users.xml b/indoteknik_custom/views/res_users.xml index cddd8253..fd2d47c8 100644 --- a/indoteknik_custom/views/res_users.xml +++ b/indoteknik_custom/views/res_users.xml @@ -37,7 +37,7 @@ <tr><td style="padding-bottom: 16px;">Kami senang Anda bergabung dengan Indoteknik.</td></tr> <tr><td style="padding-bottom: 16px;">Untuk mengaktifkan akun anda salin kode OTP berikut <strong>${object.otp_code}</strong>, lalu masukan pada kolom yang disediakan pada website Indoteknik.com</td></tr> - <tr><td style="padding-bottom: 16px;">Atau anda dapat klik tautan berikut: <a href="http://localhost:2100/register?activation=token&token=${object.activation_token}">Aktivasi akun</a></td></tr> + <tr><td style="padding-bottom: 16px;">Atau anda dapat klik tautan berikut: <a href="${object.get_activation_token_url() | safe}">Aktivasi akun</a></td></tr> <tr><td style="padding-bottom: 16px;">Jika anda mengalami kesulitan atau memiliki pertanyaan, hubungi tim dukungan kami melalui email <a href="mailto:sales@indoteknik.com">berikut</a></td></tr> <tr><td style="padding-bottom: 2px;">Hormat kami,</td></tr> |
