2018-09-22 21:23:50 +02:00
|
|
|
|
2019-05-29 15:30:23 +02:00
|
|
|
require "json"
|
|
|
|
|
2018-12-17 00:56:03 +01:00
|
|
|
class AuthD::User
|
|
|
|
getter uid : Int32
|
|
|
|
getter gid : Int32
|
2019-05-29 19:45:03 +02:00
|
|
|
getter login : String
|
|
|
|
getter password_hash : String
|
2018-12-17 00:56:03 +01:00
|
|
|
getter home : String = "/"
|
|
|
|
getter shell : String = "/bin/nologin"
|
|
|
|
getter groups = Array(String).new
|
|
|
|
getter full_name : String? = nil
|
|
|
|
getter location : String? = nil
|
|
|
|
getter office_phone_number : String? = nil
|
|
|
|
getter home_phone_number : String? = nil
|
|
|
|
getter other_contact : String? = nil
|
2019-01-14 13:46:40 +01:00
|
|
|
getter avatar : String? = nil
|
2018-09-22 21:23:50 +02:00
|
|
|
|
2018-12-17 00:56:03 +01:00
|
|
|
JSON.mapping({
|
|
|
|
login: String,
|
|
|
|
password_hash: String,
|
|
|
|
uid: Int32,
|
|
|
|
gid: Int32,
|
|
|
|
home: String,
|
|
|
|
shell: String,
|
|
|
|
groups: Array(String),
|
|
|
|
full_name: String?,
|
|
|
|
office_phone_number: String?,
|
|
|
|
home_phone_number: String?,
|
2019-05-29 19:45:03 +02:00
|
|
|
other_contact: String?,
|
|
|
|
avatar: String?
|
2018-12-17 00:56:03 +01:00
|
|
|
})
|
2018-09-22 21:23:50 +02:00
|
|
|
|
2018-12-17 00:56:03 +01:00
|
|
|
def initialize(@login, @password_hash, @uid, @gid, @home, @shell)
|
|
|
|
end
|
2018-09-22 21:23:50 +02:00
|
|
|
|
|
|
|
def to_h
|
|
|
|
{
|
2018-12-17 00:56:03 +01:00
|
|
|
:login => @login,
|
|
|
|
:password_hash => "x", # Not real hash in JWT.
|
|
|
|
:uid => @uid,
|
|
|
|
:gid => @gid,
|
|
|
|
:home => @home,
|
|
|
|
:shell => @shell,
|
|
|
|
:groups => @groups,
|
|
|
|
:full_name => @full_name,
|
|
|
|
:office_phone_number => @office_phone_number,
|
|
|
|
:home_phone_number => @home_phone_number,
|
2019-01-14 13:46:40 +01:00
|
|
|
:other_contact => @other_contact,
|
|
|
|
:avatar => @avatar
|
2018-09-22 21:23:50 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|