mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 23:24:09 +00:00
fix: setCookie in ReleaseXXX mode, spelling COOKIE
This commit is contained in:
parent
6d99e7e8da
commit
d1da4ec3bc
3 changed files with 16 additions and 4 deletions
|
@ -73,6 +73,7 @@ pub fn main() !void {
|
||||||
// since we provided "false" for duplicating strings in the call
|
// since we provided "false" for duplicating strings in the call
|
||||||
// to getCookieStr(), there won't be an allocation error
|
// to getCookieStr(), there won't be an allocation error
|
||||||
else |err| {
|
else |err| {
|
||||||
|
std.log.err("ERROR!\n", .{});
|
||||||
std.log.err("cannot check for `ZIG_ZAP` cookie: {any}\n", .{err});
|
std.log.err("cannot check for `ZIG_ZAP` cookie: {any}\n", .{err});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +84,10 @@ pub fn main() !void {
|
||||||
// .max_age_s = 60,
|
// .max_age_s = 60,
|
||||||
//
|
//
|
||||||
// check out other params: domain, path, secure, http_only
|
// check out other params: domain, path, secure, http_only
|
||||||
}) catch unreachable;
|
}) catch |err| {
|
||||||
|
std.log.err("ERROR!\n", .{});
|
||||||
|
std.log.err("cannot set cookie: {any}\n", .{err});
|
||||||
|
};
|
||||||
|
|
||||||
r.sendBody("Hello") catch unreachable;
|
r.sendBody("Hello") catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,10 +464,10 @@ pub fn UserPassSessionAuth(comptime Lookup: type, comptime lockedPwLookups: bool
|
||||||
defer self.tokenLookupLock.unlock();
|
defer self.tokenLookupLock.unlock();
|
||||||
if (self.sessionTokens.contains(cookie.str)) {
|
if (self.sessionTokens.contains(cookie.str)) {
|
||||||
// cookie is a valid session!
|
// cookie is a valid session!
|
||||||
zap.debug("Auth: COKIE IS OK!!!!: {s}\n", .{cookie.str});
|
zap.debug("Auth: COOKIE IS OK!!!!: {s}\n", .{cookie.str});
|
||||||
return .AuthOK;
|
return .AuthOK;
|
||||||
} else {
|
} else {
|
||||||
zap.debug("Auth: COKIE IS BAD!!!!: {s}\n", .{cookie.str});
|
zap.debug("Auth: COOKIE IS BAD!!!!: {s}\n", .{cookie.str});
|
||||||
// this is not necessarily a bad thing. it could be a
|
// this is not necessarily a bad thing. it could be a
|
||||||
// stale cookie from a previous session. So let's check
|
// stale cookie from a previous session. So let's check
|
||||||
// if username and password are being sent and correct.
|
// if username and password are being sent and correct.
|
||||||
|
|
10
src/zap.zig
10
src/zap.zig
|
@ -310,7 +310,15 @@ pub const SimpleRequest = struct {
|
||||||
.secure = if (args.secure) 1 else 0,
|
.secure = if (args.secure) 1 else 0,
|
||||||
.http_only = if (args.http_only) 1 else 0,
|
.http_only = if (args.http_only) 1 else 0,
|
||||||
};
|
};
|
||||||
if (fio.http_set_cookie(self.h, c) == -1) {
|
|
||||||
|
// TODO WAT?
|
||||||
|
// if we:
|
||||||
|
// if(fio.http_set_cookie(...) == -1)
|
||||||
|
// instead of capturing it in `ret` first and then checking it,
|
||||||
|
// all ReleaseXXX builds return an error!
|
||||||
|
const ret = fio.http_set_cookie(self.h, c);
|
||||||
|
if (ret == -1) {
|
||||||
|
std.log.err("fio.http_set_cookie returned: {}\n", .{ret});
|
||||||
return error.SetCookie;
|
return error.SetCookie;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue