Subversion Repositories RepoView

Rev

Rev 3 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 5
Line 1... Line 1...
1
/* $Id: cookie.c 3 2024-08-20 21:05:24Z nishi $ */
1
/* $Id: cookie.c 5 2024-08-20 22:43:56Z nishi $ */
2
 
2
 
3
#include "rv_auth.h"
3
#include "rv_auth.h"
4
 
4
 
5
#include "rv_util.h"
5
#include "rv_util.h"
-
 
6
#include "rv_db.h"
6
 
7
 
-
 
8
#include <string.h>
7
#include <stdio.h>
9
#include <stdio.h>
8
#include <stdlib.h>
10
#include <stdlib.h>
9
 
11
 
10
extern char** environ;
12
extern char** environ;
11
 
13
 
Line 66... Line 68...
66
		free(cookie);
68
		free(cookie);
67
	}
69
	}
68
}
70
}
69
 
71
 
70
char* rv_logged_in(void) {
72
char* rv_logged_in(void) {
-
 
73
	int i;
-
 
74
	for(i = 0; cookie_entries[i] != NULL; i++) {
-
 
75
		if(strcmp(cookie_entries[i]->key, "token") == 0) {
-
 
76
			return rv_who_has_token(cookie_entries[i]->value);
71
	parse_cookie();
77
			break;
-
 
78
		}
-
 
79
	}
72
	return NULL;
80
	return NULL;
73
}
81
}
74
 
82
 
-
 
83
void rv_save_login(const char* username) {
-
 
84
	char* token = rv_new_token(username);
-
 
85
	printf("Set-Cookie: token=%s; HttpOnly\r\n", token);
-
 
86
	free(token);
-
 
87
}
-
 
88
 
-
 
89
void rv_init_auth(void) { parse_cookie(); }
-
 
90
 
75
void rv_free_auth(void) {
91
void rv_free_auth(void) {
76
	int i;
92
	int i;
77
	for(i = 0; cookie_entries[i] != NULL; i++) {
93
	for(i = 0; cookie_entries[i] != NULL; i++) {
78
		free(cookie_entries[i]->key);
94
		free(cookie_entries[i]->key);
79
		free(cookie_entries[i]->value);
95
		free(cookie_entries[i]->value);