mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
Added change password
This commit is contained in:
parent
c3e7223077
commit
f73a4b1283
4 changed files with 67 additions and 8 deletions
|
|
@ -20,6 +20,7 @@
|
|||
(logout function)
|
||||
(get-profile function)
|
||||
(sign-up function)
|
||||
(change-password function)
|
||||
(make-token function)
|
||||
(load-content function)
|
||||
(create-base-tables function))
|
||||
|
|
@ -121,6 +122,54 @@ if one is present and login fails."
|
|||
:token ,(make-token))))
|
||||
(url-replace (location body) next-step)))))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
;; change-password ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun change-password (body sql-connection &key (title "Change Password")
|
||||
(next-step "/"))
|
||||
(check-type body clog-body)
|
||||
(clog-web-form
|
||||
body title
|
||||
`(("Old Password" "oldpass" :password)
|
||||
("New Password" "password" :password)
|
||||
("Retype Password" "repass" :password))
|
||||
(lambda (result)
|
||||
(cond ((not
|
||||
(equal (form-result result "password")
|
||||
(form-result result "repass")))
|
||||
(clog-web-alert body "Password Mismatch"
|
||||
"The new passwords do match."
|
||||
:time-out 3
|
||||
:place-top t))
|
||||
((< (length (form-result result "password")) 4)
|
||||
(clog-web-alert body "Password Missize"
|
||||
"The new passwords must at least 4 characters."
|
||||
:time-out 3
|
||||
:place-top t))
|
||||
(t
|
||||
(let ((contents (dbi:fetch-all
|
||||
(dbi:execute
|
||||
(dbi:prepare
|
||||
sql-connection
|
||||
"select username from users where username=? and password=?")
|
||||
(list (getf (profile (get-web-site body)) :|username|)
|
||||
(form-result result "oldpass"))))))
|
||||
(cond (contents
|
||||
(dbi:do-sql
|
||||
sql-connection
|
||||
(sql-update
|
||||
"users"
|
||||
`(:password ,(form-result result "password"))
|
||||
"username=?")
|
||||
(list (getf (profile (get-web-site body)) :|username|)))
|
||||
(url-replace (location body) next-step))
|
||||
(t
|
||||
(clog-web-alert body "Old Password"
|
||||
"Old password is incorrect."
|
||||
:time-out 3
|
||||
:place-top t)))))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;
|
||||
;; make-token ;;
|
||||
;;;;;;;;;;;;;;;;
|
||||
|
|
|
|||
BIN
static-files/img/clog-logo.png
Normal file
BIN
static-files/img/clog-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
static-files/img/clog.png
Normal file
BIN
static-files/img/clog.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -30,14 +30,15 @@
|
|||
;; /content in this case on-main. So our about page has no handler set
|
||||
;; but functions as we added to out database.
|
||||
|
||||
; Menu Menu Item URL Handler Actions Auth
|
||||
(defparameter *menu* `(("Features" (("Home" "/")
|
||||
("Login" "/login" on-login :login)
|
||||
("Signup" "/signup" on-signup :signup)
|
||||
("Content" "/content" on-main :content)
|
||||
("Logout" "/logout" on-logout :logout)))
|
||||
("Admin" (("User List" "/users" on-users :users)))
|
||||
("Help" (("About" "/content/about"))))
|
||||
; Menu Menu Item URL Handler Actions Auth
|
||||
(defparameter *menu* `(("Features" (("Home" "/")
|
||||
("Login" "/login" on-login :login)
|
||||
("Signup" "/signup" on-signup :signup)
|
||||
("Change Password" "/pass" on-new-pass :change-password)
|
||||
("Content" "/content" on-main :content)
|
||||
("Logout" "/logout" on-logout :logout)))
|
||||
("Admin" (("User List" "/users" on-users :users)))
|
||||
("Help" (("About" "/content/about"))))
|
||||
"Setup website menu")
|
||||
|
||||
(defun start-tutorial ()
|
||||
|
|
@ -46,6 +47,7 @@
|
|||
(add-authorization '(:guest :member) '(:content-show-comments))
|
||||
(add-authorization '(:guest) '(:login :signup))
|
||||
(add-authorization '(:member) '(:logout
|
||||
:change-password
|
||||
:content-comment))
|
||||
(add-authorization '(:editor) '(:content-edit))
|
||||
(add-authorization '(:admin) '(:users :content-admin))
|
||||
|
|
@ -161,3 +163,11 @@
|
|||
(dolist (user users)
|
||||
(create-div body :content (getf user :|username|))))))
|
||||
:authorize t))
|
||||
|
||||
(defun on-new-pass (body)
|
||||
(init-site body)
|
||||
(create-web-page body
|
||||
:change-password `(:menu ,*menu*
|
||||
:content ,(lambda (body)
|
||||
(change-password body *sql-connection*)))
|
||||
:authorize t))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue