From ed7881fba6e42d7ed5e027aa5819bc2c8e62ea73 Mon Sep 17 00:00:00 2001
From: Mart van Santen <mart@greenhost.nl>
Date: Wed, 1 Dec 2021 08:05:02 +0100
Subject: [PATCH] A q is not a s

---
 .gitlab-ci.yml |  6 +++---
 login/app.py   | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index abaab13..7bb899f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -194,9 +194,9 @@ behave-integration:
     SECRET: "secret"
   image: ${CI_REGISTRY_IMAGE}/behave:${CI_COMMIT_REF_NAME}
   script:
-    - curl -q http://hydra:4445/health/alive
-    - curl -q http://kratos:4433/health/alive
-    - curl -q http://oidc:5000/status
+    - curl -s http://hydra:4445/health/alive
+    - curl -s http://kratos:4433/health/alive
+    - curl -s http://oidc:5000/status
     # Steps to do:
     # - create user & access roles & grant access
     # - add client applition ID + key for testing
diff --git a/login/app.py b/login/app.py
index 68f4528..df968ac 100644
--- a/login/app.py
+++ b/login/app.py
@@ -6,6 +6,7 @@ import logging
 import os
 import click
 import urllib.parse
+import json
 
 # Flask
 from flask import abort, Flask, redirect, request, render_template
@@ -150,7 +151,58 @@ app.cli.add_command(app_cli)
 
 @user_cli.command('create')
 @click.argument('email')
-def create_user(email):
+@click.argument('password')
+def create_user(email, password):
+    app.logger.info("Creating user with email: ({0})".format(email))
+
+#    obj = User()
+#    obj.email = email
+
+    # Trying to create idenity
+    try:
+        body = AdminCreateIdentityBody(
+            schema_id="default",
+            traits={'email':email},
+        ) # AdminCreateIdentityBody |  (optional)
+        kratos_obj = KRATOS_ADMIN.admin_create_identity(admin_create_identity_body=body)
+    except ory_kratos_client.exceptions.ApiException as err:
+        if err.status == 409:
+            print("Conflict during creation of user. User already exists?")
+
+
+    data = KRATOS_ADMIN.admin_list_identities()
+
+    for id in data.value:
+        if (id.traits['email'] == email):
+            kratos_id = id.id
+
+    body = AdminCreateSelfServiceRecoveryLinkBody(
+        expires_in="15m",
+        identity_id=str(kratos_id)
+    ) # AdminCreateSelfServiceRecoveryLinkBody |  (optional)
+
+    pprint.pprint(body)
+    # Get recovery link
+    api_response = KRATOS_ADMIN.admin_create_self_service_recovery_link(
+        admin_create_self_service_recovery_link_body=body)
+
+    
+    pprint.pprint(api_response)
+    pprint.pprint(api_response.recovery_link)
+#    print (type(data))
+
+#    print(obj)
+#    for kratos_id in kratos_ids:
+ #       print(kratos_id)
+
+#    obj.kratos_id = kratos_obj.id
+
+
+
+
+@user_cli.command('invite')
+@click.argument('email')
+def invite_user(email):
     app.logger.info("Creating user with email: ({0})".format(email))
 
     obj = User()
-- 
GitLab