[UPD] odex_mobile: add jwt expire days configuration
This commit is contained in:
parent
18b0c19859
commit
9b5dc5a900
|
|
@ -914,6 +914,12 @@ msgstr "منتهي الصلاحية"
|
|||
msgid "Is System"
|
||||
msgstr "هل النظام"
|
||||
|
||||
#. module: odex_mobile
|
||||
#: model:ir.model.fields,field_description:odex_mobile.field_res_company__jwt_expire_days
|
||||
#: model:ir.model.fields,field_description:odex_mobile.field_res_config_settings__jwt_expire_days
|
||||
msgid "JWT expire (days)"
|
||||
msgstr "انتهاء صلاحية JWT (أيام)"
|
||||
|
||||
#. module: odex_mobile
|
||||
#: code:addons/odex_mobile/controllers/authentication.py:0
|
||||
#: code:addons/odex_mobile/controllers/rest_api_v2/authentication.py:0
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ class ResConfigSettings(models.TransientModel):
|
|||
auto_checkout = fields.Integer(related="company_id.auto_checkout" ,string="Auto Checkout After",readonly=False)
|
||||
fcm_server_key = fields.Char(string='Server Key:', related="company_id.fcm_server_key", readonly=False)
|
||||
service_account = fields.Binary(string='Service Account:', related="company_id.service_account", readonly=False)
|
||||
jwt_expire_days = fields.Integer(related='company_id.jwt_expire_days', readonly=False)
|
||||
sender_id = fields.Char(string='Sender ID:', related="company_id.sender_id", readonly=False)
|
||||
|
||||
class ResCompany(models.Model):
|
||||
|
|
@ -72,5 +73,6 @@ class ResCompany(models.Model):
|
|||
auto_checkout = fields.Integer(string="Auto Checkout After")
|
||||
fcm_server_key = fields.Char(string='Server Key')
|
||||
service_account = fields.Binary(string='Service Account', attachment=True)
|
||||
jwt_expire_days = fields.Integer(string="JWT expire (days)", default=14)
|
||||
sender_id = fields.Char(string='Sender ID')
|
||||
|
||||
|
|
|
|||
|
|
@ -97,10 +97,11 @@ class Validator:
|
|||
|
||||
def create_token(self, user):
|
||||
try:
|
||||
exp = datetime.datetime.utcnow() + datetime.timedelta(days=7)
|
||||
now = datetime.datetime.now(datetime.timezone.utc)
|
||||
exp = now + datetime.timedelta(days=user.company_id.jwt_expire_days or 14)
|
||||
payload = {
|
||||
'exp': exp,
|
||||
'iat': datetime.datetime.utcnow(),
|
||||
'iat': now,
|
||||
'sub': user['id'],
|
||||
'lgn': user['login'],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,12 +86,12 @@
|
|||
<h2>Odex SS App</h2>
|
||||
<div class="row mt16 o_settings_container">
|
||||
|
||||
<div class="col-xs-12 col-md-6 o_setting_box">
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="service_account"/>
|
||||
<field name="service_account"/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6 o_setting_box">
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="service_account"/>
|
||||
<field name="service_account"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-6 o_setting_box">
|
||||
<div class="o_setting_right_pane">
|
||||
|
|
@ -104,6 +104,13 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-6 o_setting_box">
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="jwt_expire_days"/>
|
||||
<field name="jwt_expire_days"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue