check.py
940 Bytes
# -*- coding: utf-8 -*-
from odoo import http
from datetime import datetime, timedelta
import json, random, string
#(datetime.now() - timedelta(hours=3)).strftime('%Y-%m-%d %H:%M')
class hgt_login(http.Controller):
"""Controlador para chequear usuario contraseña y eso"""
@http.route('/app/login_check_pass', auth='public', type='json' , website=False ,csrf=False, methods = ['POST','GET'])
def index(self, **kw):
user = kw.get('user')
passw = kw.get('pass')
user = self.login(user,passw)
rta = {"login":user[0],"id":user[1]}
return(rta)
def login(self, User, Pass):
user = http.request.env['res.users'].sudo().search([["login", "=", User]])
try:
user_id = user.id
user.sudo(user_id).check_credentials(Pass)
#user.sudo(user_id)._update_last_login()
return(True,user_id)
except:
return(False,0)