Exemple #1
0
def change_password(request):
    username = str(request.user)
    body = json.loads(request.body)
    current_password = body['currentPW']
    new_password = body['newPW']

    tas = TASClient(baseURL=settings.TAS_URL, credentials={'username': settings.TAS_CLIENT_KEY, 'password': settings.TAS_CLIENT_SECRET})
    auth = tas.authenticate(username, current_password)
    if auth:
        try:
            tas.change_password(username, current_password, new_password)
            return JsonResponse({'completed': True})
        except Exception as e:
            return JsonResponse({'message': e.args[1]}, status=422)
    else:
        return JsonResponse({'message': 'Incorrect Password'}, status=401)
Exemple #2
0
 def save(self):
     cleaned_data = self.cleaned_data
     tas = TASClient()
     tas.change_password(self._username, cleaned_data['current_password'],
                         cleaned_data['new_password'])
Exemple #3
0
 def save(self):
     cleaned_data = self.cleaned_data
     tas = TASClient()
     tas.change_password(self._username, cleaned_data['current_password'],
                         cleaned_data['new_password'])