]> gitweb.factorcode.org Git - factor.git/blob - basis/furnace/auth/providers/db/db.factor
d42ad58af623eedcc365caf3eb684026084a9293
[factor.git] / basis / furnace / auth / providers / db / db.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors db db.tuples db.types furnace.auth.providers
4 kernel ;
5 IN: furnace.auth.providers.db
6
7 user "USERS"
8 {
9     { "username" "USERNAME" { VARCHAR 256 } +user-assigned-id+ }
10     { "realname" "REALNAME" { VARCHAR 256 } }
11     { "password" "PASSWORD" BLOB +not-null+ }
12     { "salt" "SALT" INTEGER +not-null+ }
13     { "email" "EMAIL" { VARCHAR 256 } }
14     { "ticket" "TICKET" { VARCHAR 256 } }
15     { "capabilities" "CAPABILITIES" FACTOR-BLOB }
16     { "profile" "PROFILE" FACTOR-BLOB }
17     { "deleted" "DELETED" INTEGER +not-null+ }
18 } define-persistent
19
20 SINGLETON: users-in-db
21
22 M: users-in-db get-user
23     drop <user> select-tuple ;
24
25 M: users-in-db new-user
26     drop
27     [
28         user new
29             over username>> >>username
30         select-tuple [
31             drop f
32         ] [
33             dup insert-tuple
34         ] if
35     ] with-transaction ;
36
37 M: users-in-db update-user
38     drop update-tuple ;