From 6a87a12ca305d22db5532d1c645b67e9c5bf9747 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 28 Oct 2023 09:05:59 +0700 Subject: Update auth function --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/res_users.py | 22 +++++++++++++ indoteknik_custom/views/res_users.xml | 62 +++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 indoteknik_custom/views/res_users.xml (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 23abc084..000c7fe2 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -99,6 +99,7 @@ 'views/quotation_so_multi_update.xml', 'views/stock_move_line.xml', 'views/product_monitoring.xml', + 'views/res_users.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 7f94771f..02433deb 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -1,4 +1,7 @@ from odoo import models, fields +from datetime import datetime +from pytz import UTC +import random, string class ResUsers(models.Model): @@ -6,3 +9,22 @@ class ResUsers(models.Model): reset_password_token = fields.Char(string="Reset Password Token") activation_token = fields.Char(string="Activation Token") + otp_code = fields.Char(string='OTP Code') + otp_create_date = fields.Datetime(string='OTP Create Date') + + def _generate_otp(self): + for user in self: + user.otp_code = '{:04d}'.format(random.randint(0, 9999)) + user.otp_create_date = fields.Datetime.now() + + def _generate_activation_token(self): + for user in self: + token_source = string.ascii_letters + string.digits + user.activation_token = ''.join(random.choice(token_source) for i in range(21)) + + def send_activation_mail(self): + template = self.env.ref('indoteknik_custom.mail_template_res_user_activation_request') + 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 diff --git a/indoteknik_custom/views/res_users.xml b/indoteknik_custom/views/res_users.xml new file mode 100644 index 00000000..cddd8253 --- /dev/null +++ b/indoteknik_custom/views/res_users.xml @@ -0,0 +1,62 @@ + + + + Users: Activation Request + + Aktivasi Akun - Indoteknik.com + sales@indoteknik.com + ${object.login | safe} + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + +
Dear ${object.name},
Kami senang Anda bergabung dengan Indoteknik.
Untuk mengaktifkan akun anda salin kode OTP berikut ${object.otp_code}, lalu masukan pada kolom yang disediakan pada website Indoteknik.com
Atau anda dapat klik tautan berikut: Aktivasi akun
Jika anda mengalami kesulitan atau memiliki pertanyaan, hubungi tim dukungan kami melalui email berikut
Hormat kami,
PT. Indoteknik Dotcom Gemilang
+
+
+
+
+
+
+
+
\ No newline at end of file -- cgit v1.2.3