|
@@ -219,68 +219,6 @@ Boolean function check_login(user_id : String):
|
|
|
|
|
|
return password == stored_password!
|
|
|
|
|
|
-Void function new_task():
|
|
|
- String username
|
|
|
- String user_id
|
|
|
- String password
|
|
|
-
|
|
|
- // Load in a hard-reference to the previously created model
|
|
|
- core = import_node(core_model_location)
|
|
|
-
|
|
|
- caches = dict_create()
|
|
|
- dict_add_fast(caches, "models", dict_create())
|
|
|
- dict_add_fast(caches, "users", dict_create())
|
|
|
- dict_add_fast(caches, "full_name", dict_create())
|
|
|
-
|
|
|
- // Find root element
|
|
|
- Element elems
|
|
|
- String elem
|
|
|
- elems = allInstances(core, "Folder")
|
|
|
- while (set_len(elems) > 0):
|
|
|
- elem = set_pop(elems)
|
|
|
- if (value_eq(read_attribute(core, elem, "name"), "")):
|
|
|
- if (set_len(allIncomingAssociationInstances(core, elem, "contains")) == 0):
|
|
|
- dict_add_fast(caches, "root", elem)
|
|
|
- break!
|
|
|
-
|
|
|
- while (True):
|
|
|
- output("Log on as which user?")
|
|
|
- username = input()
|
|
|
-
|
|
|
- user_id = get_user_id(username)
|
|
|
- if (user_id == ""):
|
|
|
- // New user
|
|
|
- // Add user to Core Formalism
|
|
|
- user_id = instantiate_node(core, "User", "")
|
|
|
- instantiate_attribute(core, user_id, "name", username)
|
|
|
- instantiate_attribute(core, user_id, "admin", False)
|
|
|
-
|
|
|
- output("This is a new user: please give password!")
|
|
|
- password = hash(input())
|
|
|
-
|
|
|
- output("Please repeat the password")
|
|
|
- if (password == hash(input())):
|
|
|
- output("Passwords match!")
|
|
|
- instantiate_attribute(core, user_id, "password", password)
|
|
|
-
|
|
|
- // Now create a folder for this user's models!
|
|
|
- current_user_id = get_user_id("admin")
|
|
|
- create_folders(user_id, "users/" + username)
|
|
|
- current_user_id = user_id
|
|
|
- break!
|
|
|
- else:
|
|
|
- output("Not the same password!")
|
|
|
- else:
|
|
|
- if (check_login(user_id)):
|
|
|
- break!
|
|
|
- else:
|
|
|
- output("Wrong password!")
|
|
|
-
|
|
|
- user_function_skip_init(user_id)
|
|
|
-
|
|
|
- // User destroyed already, so just stop execution
|
|
|
- return!
|
|
|
-
|
|
|
String function get_entry_id(name : String):
|
|
|
Element hierarchy_split
|
|
|
String current
|
|
@@ -2432,7 +2370,63 @@ String function cmd_conformance_add(model_name : String, metamodel_name : String
|
|
|
return "Model not found: " + model_name!
|
|
|
return "Success"!
|
|
|
|
|
|
-Void function user_function_skip_init(user_id : String):
|
|
|
+Void function new_task():
|
|
|
+ String username
|
|
|
+ String user_id
|
|
|
+ String password
|
|
|
+
|
|
|
+ // Load in a hard-reference to the previously created model
|
|
|
+ core = import_node(core_model_location)
|
|
|
+
|
|
|
+ caches = dict_create()
|
|
|
+ dict_add_fast(caches, "models", dict_create())
|
|
|
+ dict_add_fast(caches, "users", dict_create())
|
|
|
+ dict_add_fast(caches, "full_name", dict_create())
|
|
|
+
|
|
|
+ // Find root element
|
|
|
+ Element elems
|
|
|
+ String elem
|
|
|
+ elems = allInstances(core, "Folder")
|
|
|
+ while (set_len(elems) > 0):
|
|
|
+ elem = set_pop(elems)
|
|
|
+ if (value_eq(read_attribute(core, elem, "name"), "")):
|
|
|
+ if (set_len(allIncomingAssociationInstances(core, elem, "contains")) == 0):
|
|
|
+ dict_add_fast(caches, "root", elem)
|
|
|
+ break!
|
|
|
+
|
|
|
+ while (True):
|
|
|
+ output("Log on as which user?")
|
|
|
+ username = input()
|
|
|
+
|
|
|
+ user_id = get_user_id(username)
|
|
|
+ if (user_id == ""):
|
|
|
+ // New user
|
|
|
+ // Add user to Core Formalism
|
|
|
+ user_id = instantiate_node(core, "User", "")
|
|
|
+ instantiate_attribute(core, user_id, "name", username)
|
|
|
+ instantiate_attribute(core, user_id, "admin", False)
|
|
|
+
|
|
|
+ output("This is a new user: please give password!")
|
|
|
+ password = hash(input())
|
|
|
+
|
|
|
+ output("Please repeat the password")
|
|
|
+ if (password == hash(input())):
|
|
|
+ output("Passwords match!")
|
|
|
+ instantiate_attribute(core, user_id, "password", password)
|
|
|
+
|
|
|
+ // Now create a folder for this user's models!
|
|
|
+ current_user_id = get_user_id("admin")
|
|
|
+ create_folders(user_id, "users/" + username)
|
|
|
+ current_user_id = user_id
|
|
|
+ break!
|
|
|
+ else:
|
|
|
+ output("Not the same password!")
|
|
|
+ else:
|
|
|
+ if (check_login(user_id)):
|
|
|
+ break!
|
|
|
+ else:
|
|
|
+ output("Wrong password!")
|
|
|
+
|
|
|
String cmd
|
|
|
String result
|
|
|
|
|
@@ -2519,11 +2513,11 @@ Void function user_function_skip_init(user_id : String):
|
|
|
set_verbose(False)
|
|
|
elif (cmd == "user_logout"):
|
|
|
output("Success")
|
|
|
- new_task()
|
|
|
- return !
|
|
|
+ // TODO fix: just do a continue in the loop
|
|
|
elif (cmd == "exit"):
|
|
|
output("Success")
|
|
|
sleep(5)
|
|
|
+ // TODO break the loop (FIX)
|
|
|
return !
|
|
|
elif (cmd == "folder_create"):
|
|
|
output(cmd_folder_create(single_input("Folder name?")))
|