2018-09-22 21:23:50 +02:00
|
|
|
|
|
|
|
require "pg"
|
|
|
|
require "crecto"
|
|
|
|
|
2018-09-22 21:42:21 +02:00
|
|
|
class AuthD::User < Crecto::Model
|
2018-09-22 21:23:50 +02:00
|
|
|
schema "users" do # table name
|
|
|
|
field :username, String
|
|
|
|
field :realname, String
|
|
|
|
field :avatar, String
|
|
|
|
field :password, String
|
|
|
|
field :perms, Array(String)
|
|
|
|
end
|
|
|
|
|
|
|
|
validate_required [:username, :password, :perms]
|
|
|
|
|
|
|
|
def to_h
|
|
|
|
{
|
|
|
|
:username => @username,
|
|
|
|
:realname => @realname,
|
|
|
|
:perms => @perms,
|
|
|
|
:avatar => @avatar
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|