1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00

fix: setCookie in ReleaseXXX mode, spelling COOKIE

This commit is contained in:
Rene Schallner 2023-05-29 18:19:25 +02:00
parent 6d99e7e8da
commit d1da4ec3bc
3 changed files with 16 additions and 4 deletions

View file

@ -73,6 +73,7 @@ pub fn main() !void {
// since we provided "false" for duplicating strings in the call
// to getCookieStr(), there won't be an allocation error
else |err| {
std.log.err("ERROR!\n", .{});
std.log.err("cannot check for `ZIG_ZAP` cookie: {any}\n", .{err});
}
@ -83,7 +84,10 @@ pub fn main() !void {
// .max_age_s = 60,
//
// 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;
}

View file

@ -464,10 +464,10 @@ pub fn UserPassSessionAuth(comptime Lookup: type, comptime lockedPwLookups: bool
defer self.tokenLookupLock.unlock();
if (self.sessionTokens.contains(cookie.str)) {
// 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;
} 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
// stale cookie from a previous session. So let's check
// if username and password are being sent and correct.

View file

@ -310,7 +310,15 @@ pub const SimpleRequest = struct {
.secure = if (args.secure) 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;
}
}