git.annexia.org
/
cocanwiki.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Edit the description fields (metadata) for images and files.
[cocanwiki.git]
/
scripts
/
login.ml
diff --git
a/scripts/login.ml
b/scripts/login.ml
index
01d325c
..
0d802ad
100644
(file)
--- a/
scripts/login.ml
+++ b/
scripts/login.ml
@@
-1,7
+1,7
@@
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: login.ml,v 1.
3 2004/09/09 12:21:22
rich Exp $
+ * $Id: login.ml,v 1.
5 2004/10/14 15:57:15
rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-35,13
+35,17
@@
let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
let permanent = try "1" = q#param "permanent" with Not_found -> false in
let redirect = try q#param "redirect" with Not_found -> "/" in
let permanent = try "1" = q#param "permanent" with Not_found -> false in
let redirect = try q#param "redirect" with Not_found -> "/" in
- let sth = dbh#prepare_cached "select id from users
+ let sth = dbh#prepare_cached "select id
, force_password_change
from users
where name = ? and password = ?
and hostid = ?" in
sth#execute [`String username; `String password; `Int hostid];
try
where name = ? and password = ?
and hostid = ?" in
sth#execute [`String username; `String password; `Int hostid];
try
- let userid = sth#fetch1int () in
+ let userid, force_password_change =
+ match sth#fetch1 () with
+ [ `Int userid; `Bool force_password_change ] ->
+ userid, force_password_change
+ | _ -> assert false in
(* Create a cookie. *)
let cookie = random_sessionid () in
(* Create a cookie. *)
let cookie = random_sessionid () in
@@
-51,6
+55,11
@@
let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
dbh#commit ();
dbh#commit ();
+ (* Force password change? *)
+ let redirect =
+ if force_password_change then "/_bin/change_password_form.cmo"
+ else redirect in
+
let cookie =
if permanent then
Cookie.cookie ~name:"auth" ~value:cookie ~path:"/" ~expires ()
let cookie =
if permanent then
Cookie.cookie ~name:"auth" ~value:cookie ~path:"/" ~expires ()
@@
-58,7
+67,9
@@
let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
Cookie.cookie ~name:"auth" ~value:cookie ~path:"/" () in
ok ~title:"Logged in" ~buttons:[ok_button redirect] ~cookie
Cookie.cookie ~name:"auth" ~value:cookie ~path:"/" () in
ok ~title:"Logged in" ~buttons:[ok_button redirect] ~cookie
- q ("Welcome back " ^ username ^ ".")
+ q ("Welcome " ^ username ^ "." ^
+ if force_password_change then " Please change your password now."
+ else "")
with
Not_found ->
error
with
Not_found ->
error