Merge pull request #2798 from FinnStutzenstein/Issue2654
Cookie handling on login
This commit is contained in:
commit
447fd35f53
@ -1,4 +1,4 @@
|
|||||||
<form ng-submit="login(username, password)">
|
<form ng-submit="login()">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<img src="/static/img/openslides-logo.png" alt="OpenSlides" class="login-logo center-block">
|
<img src="/static/img/openslides-logo.png" alt="OpenSlides" class="login-logo center-block">
|
||||||
</div>
|
</div>
|
||||||
|
@ -1486,10 +1486,11 @@ angular.module('OpenSlidesApp.users.site', [
|
|||||||
// login
|
// login
|
||||||
$scope.login = function () {
|
$scope.login = function () {
|
||||||
$scope.alerts = [];
|
$scope.alerts = [];
|
||||||
$http.post(
|
var data = { 'username': $scope.username, 'password': $scope.password };
|
||||||
'/users/login/',
|
if (!navigator.cookieEnabled) {
|
||||||
{'username': $scope.username, 'password': $scope.password}
|
data.cookies = false;
|
||||||
).then(
|
}
|
||||||
|
$http.post('/users/login/', data).then(
|
||||||
function (response) {
|
function (response) {
|
||||||
// Success: User logged in.
|
// Success: User logged in.
|
||||||
operator.setUser(response.data.user_id);
|
operator.setUser(response.data.user_id);
|
||||||
|
@ -164,6 +164,9 @@ class UserLoginView(APIView):
|
|||||||
http_method_names = ['get', 'post']
|
http_method_names = ['get', 'post']
|
||||||
|
|
||||||
def post(self, *args, **kwargs):
|
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)
|
form = AuthenticationForm(self.request, data=self.request.data)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
raise ValidationError({'detail': _('Username or password is not correct.')})
|
raise ValidationError({'detail': _('Username or password is not correct.')})
|
||||||
|
Loading…
Reference in New Issue
Block a user