예제 #1
0
func create_auth_token(ps *persist.PersistService, token string, secret string) *persist.Model { // *AuthToken {
	t := ps.New(token, map[string]string{"secret":secret});
	// t := new(AuthToken);
	// t.Token = token;
	// t.Secret = secret;
	// t.Created = time.UTC();
	// tokens.Push(*t); // TODO: obvious this is terrible "persistence"
	return t;
}
예제 #2
0
// TODO: obvious things this is terrible
func get_auth_secret(ps *persist.PersistService, auth_token string) string {
	t, found := ps.Get(auth_token);
	if found {
		return t.Data["secret"];
	}
	else {
		return "BAD_TOKEN"; // TODO better handling
	}
	panic("unreachable");
	// for n := range tokens.Data() {
	// 	t := tokens.At(n);
	// 	token, _ := t.(AuthToken);
	// 	if token.Token == auth_token { return token.Secret };
	// }
	// return "BAD_TOKEN"; // TODO: better handling this is terrible
}