aboutsummaryrefslogtreecommitdiff
path: root/src/guff/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/guff/api')
-rw-r--r--src/guff/api/methods.cr20
-rw-r--r--src/guff/api/test.cr10
2 files changed, 28 insertions, 2 deletions
diff --git a/src/guff/api/methods.cr b/src/guff/api/methods.cr
index 970e41f..fce6911 100644
--- a/src/guff/api/methods.cr
+++ b/src/guff/api/methods.cr
@@ -368,7 +368,7 @@ module Guff
},
"add_user": {
- text: "Add new user",
+ text: "Test add new user",
args: {
"name": {
@@ -402,6 +402,24 @@ module Guff
},
},
},
+
+ "login": {
+ text: "Test user login.",
+
+ args: {
+ "email": {
+ text: "Email address of user",
+ type: :text,
+ required: true,
+ },
+
+ "password": {
+ text: "Password of user",
+ type: :text,
+ required: true,
+ },
+ },
+ },
}
}
diff --git a/src/guff/api/test.cr b/src/guff/api/test.cr
index 059f670..448cadf 100644
--- a/src/guff/api/test.cr
+++ b/src/guff/api/test.cr
@@ -82,7 +82,7 @@ module Guff::API::TestAPI
user_id = @models.user.add_user(args["name"].not_nil!,
active: args["active"]? ? args["active"] == "t" : nil,
role: args["role"]?,
- email: args["name"]?,
+ email: args["email"]?,
password: args["password"]?,
)
{ "ok": true, "user_id": user_id }
@@ -120,4 +120,12 @@ module Guff::API::TestAPI
@models.user.remove_login(args["user_id"].to_i)
{ "ok": true }
end
+
+ private def do_test_login(
+ context : HTTP::Server::Context,
+ args : Hash(String, String)
+ )
+ user_id = @models.user.login(args["email"], args["password"]).to_i
+ { "ok": true, "user_id": user_id }
+ end
end