Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
54ba36c1
Commit
54ba36c1
authored
Oct 09, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check_login_form_submission() factored in separate function
parent
50773505
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
23 deletions
+26
-23
cookie_auth.c
examples/cookie_authentication/cookie_auth.c
+26
-23
No files found.
examples/cookie_authentication/cookie_auth.c
View file @
54ba36c1
...
...
@@ -40,12 +40,9 @@ static int check_auth(struct mg_connection *conn) {
return
MG_FALSE
;
}
static
int
serve_request
(
struct
mg_connection
*
conn
)
{
static
int
check_login_form_submission
(
struct
mg_connection
*
conn
)
{
char
name
[
100
],
password
[
100
],
ssid
[
100
],
expire
[
100
],
expire_epoch
[
100
];
// Always authorize requests to login page
if
(
strcmp
(
conn
->
uri
,
s_login_uri
)
==
0
&&
strcmp
(
conn
->
request_method
,
"POST"
)
==
0
)
{
mg_get_var
(
conn
,
"name"
,
name
,
sizeof
(
name
));
mg_get_var
(
conn
,
"password"
,
password
,
sizeof
(
password
));
...
...
@@ -65,11 +62,17 @@ static int serve_request(struct mg_connection *conn) {
ssid
,
expire
);
return
MG_TRUE
;
}
}
return
MG_FALSE
;
}
static
int
serve_request
(
struct
mg_connection
*
conn
)
{
if
(
strcmp
(
conn
->
uri
,
s_login_uri
)
==
0
&&
strcmp
(
conn
->
request_method
,
"POST"
)
==
0
)
{
return
check_login_form_submission
(
conn
);
}
return
MG_FALSE
;
// Serve files in the document_root
}
static
int
ev_handler
(
struct
mg_connection
*
conn
,
enum
mg_event
ev
)
{
switch
(
ev
)
{
case
MG_AUTH
:
return
check_auth
(
conn
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment