seitime-frappe/frappe/chat/__init__.py
Aditya Hase 837bfc0995 fix(unicode): Import unicode_literals in every file (#6805)
* fix(unicode): Import unicode_literals in every file

* fix(unicode): Test if safe_json_loads return unicode instead of bytes
2019-01-25 11:56:27 +05:30

23 lines
No EOL
493 B
Python

from __future__ import unicode_literals
import frappe
from frappe import _
session = frappe.session
def authenticate(user, raise_err = True):
if session.user == 'Guest':
if not frappe.db.exists('Chat Token', user):
if raise_err:
frappe.throw(_("Sorry, you're not authorized."))
else:
return False
else:
return True
else:
if user != session.user:
if raise_err:
frappe.throw(_("Sorry, you're not authorized."))
else:
return False
else:
return True