Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PizieDust committed Oct 24, 2024
1 parent a0ec9c0 commit 1c20c0b
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 52 deletions.
25 changes: 25 additions & 0 deletions dashboard.ml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,31 @@ let dashboard_layout (user : User_model.user) ~icon
[];
span [ txt "Activity" ];
];
a
~a:
[
a_href "/account";
a_class
[
"hover:bg-gray-200 hover:text-primary-400 \
font-semibold hover:font-bold \
cursor-pointer rounded p-2 w-full flex \
items-center space-x-1";
];
]
[
i
~a:
[
a_class
[
"fa-solid fa-user text-primary-500 \
text-sm";
];
]
[];
span [ txt "My Account" ];
];
hr ~a:[ a_class [ "my-4" ] ] ();
a
~a:
Expand Down
13 changes: 9 additions & 4 deletions middleware.ml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
type handler = Httpaf.Reqd.t -> unit Lwt.t
type middleware = handler -> handler

let get_csrf now =
let has_header ~header_name reqd =
let headers = (Httpaf.Reqd.request reqd).headers in
Httpaf.Headers.get headers header_name

let user_agent reqd = has_header ~header_name:"User-Agent" reqd

let get_csrf now reqd =
User_model.(
generate_cookie ~name:"molly_csrf"
generate_cookie ~name:"molly_csrf" ~user_agent:(user_agent reqd)
~uuid:(Uuidm.to_string (generate_uuid ()))
~created_at:now ~expires_in:3600)

let has_cookie cookie_name (reqd : Httpaf.Reqd.t) =
let headers = (Httpaf.Reqd.request reqd).headers in
match Httpaf.Headers.get headers "Cookie" with
match has_header ~header_name:"Cookie" reqd with
| Some cookies ->
let cookie_list = String.split_on_char ';' cookies in
List.find_opt
Expand Down
Loading

0 comments on commit 1c20c0b

Please sign in to comment.