|
@@ -32,6 +32,18 @@ Void function main():
|
|
|
core = instantiate_model(import_node(core_location))
|
|
|
export_node(core_model_location, core)
|
|
|
|
|
|
+ // Switch all new users to the user_function
|
|
|
+ // This accesses the bootstrap level, so do not change this unless you know what you are doing
|
|
|
+ Element root
|
|
|
+ Element prev
|
|
|
+ root = read_root()
|
|
|
+ root = root["__hierarchy"]["__IP"]
|
|
|
+ while (value_neq(root, !call)):
|
|
|
+ prev = root
|
|
|
+ root = root["next"]
|
|
|
+ dict_delete(prev, "next")
|
|
|
+ dict_add(prev, "next", user_function["body"])
|
|
|
+
|
|
|
// Create admin group
|
|
|
admin_group = instantiate_node(core, "Group", "")
|
|
|
instantiate_attribute(core, admin_group, "name", "admin")
|
|
@@ -46,6 +58,23 @@ Void function main():
|
|
|
instantiate_attribute(core, admin_user, "name", input())
|
|
|
instantiate_attribute(core, admin_user, "admin", True)
|
|
|
|
|
|
+ Boolean ct
|
|
|
+ String password
|
|
|
+
|
|
|
+ ct = True
|
|
|
+ while (ct):
|
|
|
+ output("Desired password for admin user?")
|
|
|
+ password = hash(input())
|
|
|
+
|
|
|
+ output("Please repeat the password")
|
|
|
+ if (password == hash(input())):
|
|
|
+ output("Passwords match!")
|
|
|
+ output("User created")
|
|
|
+ instantiate_attribute(core, admin_user, "password", password)
|
|
|
+ ct = False
|
|
|
+ else:
|
|
|
+ output("Not the same password, please try again!")
|
|
|
+
|
|
|
// Create link between admin user and group
|
|
|
instantiate_link(core, "ownedBy", "", admin_group, admin_user)
|
|
|
instantiate_link(core, "belongsTo", "", admin_user, admin_group)
|
|
@@ -83,18 +112,6 @@ Void function main():
|
|
|
instantiate_link(core, "group", "", core_model, admin_group)
|
|
|
instantiate_link(core, "owner", "", core_model, admin_user)
|
|
|
|
|
|
- // Switch all new users to the user_function
|
|
|
- // This accesses the bootstrap level, so do not change this unless you know what you are doing
|
|
|
- Element root
|
|
|
- Element prev
|
|
|
- root = read_root()
|
|
|
- root = root["__hierarchy"]["__IP"]
|
|
|
- while (value_neq(root, !call)):
|
|
|
- prev = root
|
|
|
- root = root["next"]
|
|
|
- dict_delete(prev, "next")
|
|
|
- dict_add(prev, "next", user_function["body"])
|
|
|
-
|
|
|
// Call this for ourselves as well
|
|
|
user_function_skip_init(admin_user)
|
|
|
|
|
@@ -173,17 +190,19 @@ Boolean function allow_group_modify(user_id : String, group_id : String):
|
|
|
|
|
|
Boolean function check_login(user_id : String):
|
|
|
String password
|
|
|
+ String stored_password
|
|
|
+
|
|
|
+ stored_password = read_attribute(core, user_id, "password")
|
|
|
|
|
|
output("Password for existing user?")
|
|
|
- password = input()
|
|
|
+ password = hash(input())
|
|
|
|
|
|
- return True!
|
|
|
+ return password == stored_password!
|
|
|
|
|
|
Element function user_function():
|
|
|
String username
|
|
|
String user_id
|
|
|
-
|
|
|
- output("Log on as which user?")
|
|
|
+ String password
|
|
|
|
|
|
// Load in all global variables, as this code is hotloaded!
|
|
|
Element root
|
|
@@ -201,6 +220,7 @@ Element function user_function():
|
|
|
exec(root["core/core_algorithm.alc"]["initializers"])
|
|
|
core = import_node("models/core")
|
|
|
|
|
|
+ output("Log on as which user?")
|
|
|
username = input()
|
|
|
|
|
|
user_id = get_user_id(username)
|
|
@@ -211,11 +231,29 @@ Element function user_function():
|
|
|
instantiate_attribute(core, user_id, "name", username)
|
|
|
instantiate_attribute(core, user_id, "admin", False)
|
|
|
|
|
|
+ Boolean ct
|
|
|
+ ct = True
|
|
|
+
|
|
|
+ while (ct):
|
|
|
+ output("This is a new user: please give password!")
|
|
|
+ password = hash(input())
|
|
|
+
|
|
|
+ output("Please repeat the password")
|
|
|
+ if (password == hash(input())):
|
|
|
+ output("Passwords match!")
|
|
|
+ output("User created")
|
|
|
+ instantiate_attribute(core, user_id, "password", password)
|
|
|
+ ct = False
|
|
|
+ else:
|
|
|
+ output("Not the same password, please try again!")
|
|
|
+
|
|
|
// Now call with user created
|
|
|
user_function_skip_init(user_id)
|
|
|
else:
|
|
|
- if (check_login(user_id)):
|
|
|
- user_function_skip_init(user_id)
|
|
|
+ while (bool_not(check_login(user_id))):
|
|
|
+ output("Wrong password! Try again")
|
|
|
+
|
|
|
+ user_function_skip_init(user_id)
|
|
|
|
|
|
// User destroyed already, so just stop execution
|
|
|
// TODO return a fresh node as otherwise the compiler doesn't take this
|