예제 #1
0
    def post(self, request):
        username = request.data["username"]
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            return Response({"status": "user_not_found"})

        new_password = utils.generate_password()
        user.set_password(new_password)
        user.save()

        send_password(user, new_password)
        return Response({"status": "ok"})
예제 #2
0
    def post(self, request):
        username = request.data["username"]
        first_name = request.data["name"]

        new_password = utils.generate_password()
        try:
            user = User.objects.get(username=username)
            user.set_password(new_password)
            user.first_name = first_name
            user.save()
        except User.DoesNotExist:
            user = User.objects.create_user(username, username, new_password)
            user.first_name = first_name
            user.save()

        send_password(user, new_password)
        return Response({"status": "ok"})
예제 #3
0
파일: apikey.py 프로젝트: epfl-si/amm
 def __generate_secret_key(self):
     """
     Generate the secret key (private part)
     """
     self.secret_key_clear = utils.generate_password(40)
예제 #4
0
    def test_generate_password(self):
        password = utils.generate_password(32)

        self.assertEqual(32, len(password))
예제 #5
0
파일: apikey.py 프로젝트: epfl-si/amm
 def __generate_salt(self):
     """
     Generate the salt
     """
     self.salt = utils.generate_password(20)