blob: 8a33082f6f320dc419e660fa67d1cbb1a4e5d877 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
const std = @import("std");
const memora = @import("memora");
const Context = memora.Context;
const Storage = memora.Storage;
const Body = struct {
user: []const u8,
password: []const u8,
};
const Result = struct {
success: bool,
};
pub const access = .everyone;
pub fn post(ctx: *Context, body: Body) anyerror!Result {
var user = Storage.User.open(ctx.storage, body.user) catch return .{
.success = false
};
defer user.deinit();
const result = Result {
.success = user.check_password(body.password)
};
if (result.success) {
const session = try ctx.storage.sessions.add(ctx.storage, user.info);
ctx.response.headers.fingerprint = session.fingerprint;
}
return result;
}
|