how to retrieve password in django

后端 未结 5 1149
灰色年华
灰色年华 2020-12-15 18:16

How do we retrieve a password of an user?

u = User.objects.get(username__exact=username)
print u.password

displays sha1$f0971$441cac8

5条回答
  •  忘掉有多难
    2020-12-15 19:01

    no. and there shouldn't be. as part of the security, passwords are passed through a one-way function before they are saved, so that they aren't reveled if the database is compromised

    what you can do is replace the user's password with one you know. this is how (good) site's "forgot your password" functions work: they send you a new random password, not your old one, since they (shouldn't) have access to it

提交回复
热议问题