1.在url.py裡增加,(r'^accounts/login/$', 'django.contrib.auth.views.login'),這裡,處理url的view,是系統自帶的。django.contrib.auth.views.login的功能有以下2個:
a.若為get,它在同乙個url中顯示乙個login form;
b.若為post,它將嘗試登入。如果login成功,它將重新定向到next所指定的url中,若不成功,將重新顯示登入框。
[xhtml]view plain
copy
<
body
>
<
h1>
user login
h1>
<
p>
your username and password didn't match.
please try again.
p>
<
form
method
="post"
action
="."
>
<
p>
<
label
for=
"id_username"
>
username:
label
>}p
>
<
p>
<
label
for=
"id_password"
>
password:
label
>}p
>
<
input
type
="hidden"
name
="next"
value
="/"
/>
<
input
type
="submit"
value
="login"
/>
form
>
body
>
第12行就是指定當login失敗時要重定向的路徑。
以上兩步就可以完成乙個簡單的認證過程了。
django的使用者認證實現過程
django的使用者認證實現過程 1.在url.py裡增加,r accounts login django.contrib.auth.views.login 這裡,處理url的view,是系統自帶的。django.contrib.auth.views.login的功能有以下2個 a.若為get,它在...
Cookie based認證實現
引用 使用asp.net 4.x 中的時候一定都用過forms認證即formsauthentication做登入使用者的身份認證,formsauthentication的核心就是cookie,asp.net會將使用者名稱儲存在cookie中。但是它很難進行擴充套件,更無法與第三方認證整合,因此,在 ...
RSA的簽名認證實現
大致 如下 filestream objfile file openread test.txt hashalgorithm md5 hashalgorithm create md5 byte hashdata md5 computehash objfile console writeline con...