Merge pull request #2798 from FinnStutzenstein/Issue2654

Cookie handling on login
This commit is contained in:
Norman Jäckel 2016-12-19 15:52:41 +01:00 committed by GitHub
commit 447fd35f53
3 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,4 @@
<form ng-submit="login(username, password)">
<form ng-submit="login()">
<div class="modal-header">
<img src="/static/img/openslides-logo.png" alt="OpenSlides" class="login-logo center-block">
</div>

View File

@ -1486,10 +1486,11 @@ angular.module('OpenSlidesApp.users.site', [
// login
$scope.login = function () {
$scope.alerts = [];
$http.post(
'/users/login/',
{'username': $scope.username, 'password': $scope.password}
).then(
var data = { 'username': $scope.username, 'password': $scope.password };
if (!navigator.cookieEnabled) {
data.cookies = false;
}
$http.post('/users/login/', data).then(
function (response) {
// Success: User logged in.
operator.setUser(response.data.user_id);

View File

@ -164,6 +164,9 @@ class UserLoginView(APIView):
http_method_names = ['get', 'post']
def post(self, *args, **kwargs):
# If the client tells that cookies are disabled, do not continue as guest (if enabled)
if not self.request.data.get('cookies', True):
raise ValidationError({'detail': _('Cookies have to be enabled to use OpenSlides.')})
form = AuthenticationForm(self.request, data=self.request.data)
if not form.is_valid():
raise ValidationError({'detail': _('Username or password is not correct.')})