Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
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.

35 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # kate: space-indent on; indent-width 4; replace-tabs on;
  3. """
  4. * Copyright (C) 2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
  5. *
  6. * djExtDirect is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This package is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. """
  16. def login( request, username, passwd ):
  17. from django.contrib.auth import authenticate, login as djlogin
  18. if request.user.is_authenticated():
  19. return { 'success': True }
  20. user = authenticate( username=username, password=passwd )
  21. if user:
  22. if user.is_active:
  23. djlogin( request, user )
  24. return { 'success': True }
  25. else:
  26. return { 'success': False, 'error': 'account disabled' }
  27. else:
  28. return { 'success': False, 'error': 'invalid credentials' }
  29. def logout( request ):
  30. from django.contrib.auth import logout as djlogout
  31. djlogout( request )
  32. return { 'success': True }