No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

users.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536
  1. # -*- coding: utf-8 -*-
  2. from .base import get_response
  3. from ...exceptions import *
  4. from ...client import WebUiClient as WebUiClient
  5. from lodel import logger
  6. import leapi_dyncode as dyncode
  7. ##@brief These functions are called by the rules defined in ../urls.py
  8. ## Their goal is to handle the user authentication
  9. ##@brief Controller's function to login a user, the corresponding form is in interface/users
  10. # @param request : the request (get or post)
  11. # @note the response is given in a html page called in get_response_function
  12. def signin(request):
  13. msg=''
  14. # The form send the login and password, we can authenticate the user
  15. if request.method == 'POST':
  16. login = request.form['inputLogin']
  17. WebUiClient.authenticate(login, request.form['inputPassword'])
  18. # We get the informations about the user
  19. uid=WebUiClient['__auth_user_infos']['uid']
  20. leoclass=WebUiClient['__auth_user_infos']['leoclass']
  21. query_filter=list()
  22. query_filter.append((leoclass.uid_fieldname()[0],'=', uid))
  23. user = leoclass.get(query_filter)
  24. return get_response('users/welcome.html', username = user[0].data('login'))
  25. else:
  26. return get_response('users/signin.html')
  27. ##@brief Controller's function to logout a user
  28. # @param request : the request (get or post)
  29. # @note the response is given in the login html page
  30. def signout(request):
  31. WebUiClient.destroy()
  32. return get_response('users/signin.html')