diff --git a/web/users_static/Main.tscn b/web/users_static/Main.tscn new file mode 100644 index 0000000..e4802b2 --- /dev/null +++ b/web/users_static/Main.tscn @@ -0,0 +1,99 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://WebServerSimple.gd" type="Script" id=1] +[ext_resource path="res://WebRoot.gd" type="Script" id=2] + +[sub_resource type="User" id=1] +user_id = 0 +user_name = "test" +email = "test@test.test" +pre_salt = "0e40ce1db0133a483c574b47b96d29494dfe8be759697b6d0480b0a0cef58a33" +post_salt = "c85bdbfd747d3779d158b0658e9c7eb8b7fac130f15e935469b329d115a1b044" +password_hash = "14588e720d4d3ba2b0370e6707f35940a97c8db66427ceb1990188d2c1357bd0" + +[sub_resource type="User" id=2] +user_id = 1 +user_name = "test2" +email = "test2@test2.test2" +pre_salt = "bc6ade172d7444b76b099618a1059f42c7cdadfbdafa201742b88b0f05eca4a4" +post_salt = "01d3fcc124fa170e87c7cfd91d9e5babb3ee7171590b2964681086a248da2a73" +password_hash = "97bd09b4d567ee0b02aeb8f6a8e44036b8776a8de3109add4fc05753582f5ef2" + +[sub_resource type="SessionSetupWebServerMiddleware" id=3] + +[sub_resource type="UserSessionSetupWebServerMiddleware" id=4] + +[sub_resource type="CSRFTokenWebServerMiddleware" id=5] +ignored_urls = PoolStringArray( "/user/login", "/user/register" ) + +[node name="Main" type="Node"] + +[node name="UserManagerStatic" type="UserManagerStatic" parent="."] +users = [ SubResource( 1 ), SubResource( 2 ) ] + +[node name="WebServerSimple" type="WebServerSimple" parent="."] +script = ExtResource( 1 ) + +[node name="WebRoot" type="WebRoot" parent="WebServerSimple"] +www_root_path = "res://www/" +middlewares = [ SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ] +script = ExtResource( 2 ) +menu_str = "
+index
+login
+register
+settings
+logout
+
+ +" + +[node name="StaticWebPage" type="StaticWebPage" parent="WebServerSimple/WebRoot"] +uri_segment = "/" +data = " +You can go and log in on the users page here: Login
+
+Note that in this demo sessions are not saved, and will get lost from the app if you restart it.
+
+You can also try registratition. It will work, but it will forget new users on restart. Normally in an app setup like this you wonldn't add a registration node.
+
+You can make permanent users using the UserManagerStatic node's properties using the editor.
+
+2 Users are available by default:
+
+username: test
+password: test
+
+and
+
+username: test2
+password: test2
+
+" + +[node name="UserWebPage" type="UserWebPage" parent="WebServerSimple/WebRoot"] +uri_segment = "user" +logged_out_render_type = 1 +logged_out_redirect_url = "/user/login" + +[node name="UserLoginWebPage" type="UserLoginWebPage" parent="WebServerSimple/WebRoot/UserWebPage"] +uri_segment = "login" +logged_in_render_type = 1 +logged_in_redirect_url = "/" + +[node name="UserRegisterWebPage" type="UserRegisterWebPage" parent="WebServerSimple/WebRoot/UserWebPage"] +uri_segment = "register" +logged_in_render_type = 1 +logged_in_redirect_url = "/" + +[node name="UserLogoutWebPage" type="UserLogoutWebPage" parent="WebServerSimple/WebRoot/UserWebPage"] +uri_segment = "logout" +logged_out_render_type = 1 +logged_out_redirect_url = "/" + +[node name="UserSettingsWebPage" type="UserSettingsWebPage" parent="WebServerSimple/WebRoot/UserWebPage"] +uri_segment = "settings" +logged_out_render_type = 1 +logged_out_redirect_url = "/user/login" + +[node name="HTTPSessionManager" type="HTTPSessionManager" parent="WebServerSimple"] diff --git a/web/users_static/WebRoot.gd b/web/users_static/WebRoot.gd new file mode 100644 index 0000000..8697445 --- /dev/null +++ b/web/users_static/WebRoot.gd @@ -0,0 +1,18 @@ +extends WebRoot + +export(String, MULTILINE) var menu_str : String + +func _render_main_menu(request: WebServerRequest) -> void: + # You can render the menu differently for logged in users for example + # The middlewares will run before routing (in order they are in the middlewares property) + request.body += menu_str + + # The UserSessionSetupWebServerMiddleware makes this available here: + # If you want to do this manually, you can do it via request.session + the UserDB singleton + # I recommend looking at the middleware code on the engine c++ side to see an example + var user : User = request.get_meta("user") + + if user: + request.body += "You are logged in as : " + user.user_name + ".

" + else: + request.body += "You are not logged in.

" diff --git a/web/users_static/WebServerSimple.gd b/web/users_static/WebServerSimple.gd new file mode 100644 index 0000000..9c7d7e9 --- /dev/null +++ b/web/users_static/WebServerSimple.gd @@ -0,0 +1,16 @@ +extends WebServerSimple + + +# Declare member variables here. Examples: +# var a: int = 2 +# var b: String = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + start() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta: float) -> void: +# pass diff --git a/web/users_static/default_env.tres b/web/users_static/default_env.tres new file mode 100644 index 0000000..4f08e8f --- /dev/null +++ b/web/users_static/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment3D" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/web/users_static/icon.png b/web/users_static/icon.png new file mode 100644 index 0000000..87f1f75 Binary files /dev/null and b/web/users_static/icon.png differ diff --git a/web/users_static/icon.png.import b/web/users_static/icon.png.import new file mode 100644 index 0000000..a4c02e6 --- /dev/null +++ b/web/users_static/icon.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/web/users_static/project.pandemonium b/web/users_static/project.pandemonium new file mode 100644 index 0000000..6ae35c5 --- /dev/null +++ b/web/users_static/project.pandemonium @@ -0,0 +1,25 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +[application] + +config/name="Users Static" +run/main_scene="res://Main.tscn" +config/icon="res://icon.png" + +[physics] + +common/enable_pause_aware_picking=true + +[rendering] + +vram_compression/import_etc=true +vram_compression/import_etc2=false +environment/default_environment="res://default_env.tres"