1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2025-11-12 17:09:16 +01:00
lodel2_mirror/plugins/webui/interface/controllers/users.py
Yann c3137b658f Replaced imports by LodelContext.expose_modules() calls
Theorically all of those imports were tested by unit testing, but we've got no inssurance about that.
And even if unit tests had check for syntax errors, all pieces of code were not tested. We cannot
be sure that an import was missed or forgotten...
2016-11-02 17:03:22 +01:00

38 lines
1.5 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
from .base import get_response
from ...exceptions import *
from ...client import WebUiClient as WebUiClient
from lodel.context import LodelContext
LodelContext.expose_modules(globals(), {'lodel.logger': 'logger'})
import leapi_dyncode as dyncode #TODO : handle this with context
##@brief These functions are called by the rules defined in ../urls.py
## Their goal is to handle the user authentication
##@brief Controller's function to login a user, the corresponding form is in interface/users
# @param request : the request (get or post)
# @note the response is given in a html page called in get_response_function
def signin(request):
msg=''
# The form send the login and password, we can authenticate the user
if request.method == 'POST':
login = request.form['inputLogin']
WebUiClient.authenticate(login, request.form['inputPassword'])
# We get the informations about the user
uid=WebUiClient['__auth_user_infos']['uid']
leoclass=WebUiClient['__auth_user_infos']['leoclass']
query_filter=list()
query_filter.append((leoclass.uid_fieldname()[0],'=', uid))
user = leoclass.get(query_filter)
return get_response('users/welcome.html', username = user[0].data('login'))
else:
return get_response('users/signin.html')
##@brief Controller's function to logout a user
# @param request : the request (get or post)
# @note the response is given in the login html page
def signout(request):
WebUiClient.destroy()
return get_response('users/signin.html')