diff --git a/Otakians/MainLayout.razor b/Otakians/MainLayout.razor index 109decd..2404915 100644 --- a/Otakians/MainLayout.razor +++ b/Otakians/MainLayout.razor @@ -1,11 +1,21 @@ @inherits LayoutComponentBase +@using System.Text.RegularExpressions +@using System.ComponentModel.DataAnnotations @inject HttpClient httpClient +@inject Blazored.LocalStorage.ILocalStorageService localStorage - Primary + Clear cookies - BT + @if (!isLoggedIn) + { + + Log-in or sign-up here + + + } + ? @@ -17,11 +27,23 @@ - - Store - Library - Community - + @if (isLoggedIn) + { + + Store + Library + Community + + } + else + { + + + Log-in + Sign-up + + + } @@ -29,33 +51,138 @@ +@*Sign-in overlay*@ + + + + + Sign-up + + + + + + + + I agree with Terms Of Service + + Register + + + + + +@*Log-in overlay*@ + + + Login + + @code { bool openContentDrawer = false; bool openProfileDrawer = false; + bool isLoggedIn = false; + bool isSigningUp = false; + bool isLoggingIn = false; + bool isValid = false; + User tempUser = new User(); + + #region Drawers and overlays void ToggleDrawer() { - Console.WriteLine("Open!"); openProfileDrawer = !openProfileDrawer; } + void ShowSignUp() + { + isSigningUp = true; + openContentDrawer = openProfileDrawer = false; + } + + void ShowLogIn() + { + isLoggingIn = true; + openContentDrawer = openProfileDrawer = false; + } + + void HideOverlays() => isSigningUp = isLoggingIn = false; +#endregion + + async void AddUser() + { + //await httpClient.PostAsJsonAsync("https://globalchat-4a89f-default-rtdb.europe-west1.firebasedatabase.app/Database/Users.json", new User()); + Console.WriteLine(tempUser.Username); + Console.WriteLine(tempUser.Email); + Console.WriteLine(tempUser.Password); + } + + #region Signup + bool success; + string[] errors = { }; + MudTextField pwField1; + MudForm form; + + private IEnumerable PasswordStrength(string pw) + { + if (string.IsNullOrWhiteSpace(pw)) + { + yield return "Password is required!"; + yield break; + } + if (pw.Length < 8) + yield return "Password must be at least of length 8"; + if (!Regex.IsMatch(pw, @"[A-Z]")) + yield return "Password must contain at least one capital letter"; + if (!Regex.IsMatch(pw, @"[a-z]")) + yield return "Password must contain at least one lowercase letter"; + if (!Regex.IsMatch(pw, @"[0-9]")) + yield return "Password must contain at least one digit"; + } + + private string PasswordMatch(string arg) + { + if (pwField1.Value != arg) + return "Passwords don't match"; + return null; + } + #endregion + + protected override async Task OnInitializedAsync() + { + // Reads "cookie" + var cookieContent = await localStorage.GetItemAsync("cookieName"); + + if (cookieContent == null) + { + Console.WriteLine("Cookie is blank"); + } + else + { + Console.WriteLine("We have a cookie with contents: " + cookieContent); + } + } + + async void ClearAllCookies() + { + await localStorage.ClearAsync(); + } + public class User { - public string ID { get; set; } = "null"; - public string Username { get; set; } = "null"; - public string Email { get; set; } = "null"; - public string Password { get; set; } = "null"; - } - - async void AddUser() - { - await httpClient.PostAsJsonAsync("https://globalchat-4a89f-default-rtdb.europe-west1.firebasedatabase.app/Database/Users.json", new User()); - } - - protected override async Task OnInitializedAsync() - { - //Response.Cookies.Append("MyCookie", "value1"); + public string? Username { get; set; } + public string? Email { get; set; } + public string? Password { get; set; } } } \ No newline at end of file diff --git a/Otakians/Pages/Chatting.razor b/Otakians/Pages/Chatting.razor index 2a1a7ad..dfa41d6 100644 --- a/Otakians/Pages/Chatting.razor +++ b/Otakians/Pages/Chatting.razor @@ -2,11 +2,20 @@ @using System.Globalization; @inject NavigationManager NavManager @inject HttpClient Http - +@inject IJSRuntime JSRuntime + + - + @if (messages != null) { @@ -14,48 +23,33 @@ { Message message = messages[i]; - - - - @message.Content - @("@" + message.Name) - - @(DateTime.Now.ToString("dd/MM/yyyy HH:mm", danishCulture)) + if ("dumb zhen" == message.Name) + { + + + + @message.Content + @("@" + message.Name) + + @(DateTime.Now.ToString("dd/MM/yyyy HH:mm", danishCulture)) + - + } + else + { + + + + @message.Content + @("@" + message.Name) + + @(DateTime.Now.ToString("dd/MM HH:mm", danishCulture)) + + + } } } - - - - World! - @("@Alex") - - @(DateTime.Now.ToString("dd/MM/yyyy HH:mm", danishCulture)) - - - - - - - How about a longer thing here?!?!?! Test testes tetst estestse testset estsete stestest - @("@Adam") - - @(DateTime.Now.ToString("dd/MM/yyyy HH:mm", danishCulture)) - - - - - - - It is working! - @("@Alex") - - @(DateTime.Now.ToString("dd/MM/yyyy HH:mm", danishCulture)) - - - @@ -94,13 +88,25 @@ protected override async Task OnInitializedAsync() { - if (messages == null) + messages = (await Http.GetFromJsonAsync("https://globalchat-4a89f-default-rtdb.europe-west1.firebasedatabase.app/Database/Messages.json")); + + StartLoop(); + } + + bool isLooping = false; + private async Task StartLoop() + { + if (isLooping) + return; + + isLooping = true; + + while (isLooping) + { messages = (await Http.GetFromJsonAsync("https://globalchat-4a89f-default-rtdb.europe-west1.firebasedatabase.app/Database/Messages.json")); - - //for (int i = 0; i < messages.Length; i++) - //{ - // Console.WriteLine($"Name: {messages[i].Name} Content: {messages[i].Content}"); - //} + + await Task.Delay(100000); // Delay for 1 second before the next iteration + } } public class Message diff --git a/Otakians/Pages/Posts.razor b/Otakians/Pages/Posts.razor index f856bec..b3b4fbf 100644 --- a/Otakians/Pages/Posts.razor +++ b/Otakians/Pages/Posts.razor @@ -18,8 +18,8 @@ } - - + + @@ -31,7 +31,7 @@ - + I am sorry diff --git a/Otakians/Pages/TermsOfService.razor b/Otakians/Pages/TermsOfService.razor new file mode 100644 index 0000000..fb55282 --- /dev/null +++ b/Otakians/Pages/TermsOfService.razor @@ -0,0 +1,18 @@ +@page "/TOS" + + + +
+

Terms of Service (TOS) for Otakians Social Media Platform

Effective Date: 19/5/2023

Welcome to Otakians! These Terms of Service ("TOS") govern your use of the Otakians social media platform (the "Platform"). By accessing or using the Platform, you agree to be bound by these TOS. If you do not agree to these TOS, please refrain from using the Platform.

+
1 - Acceptance of Terms

1.1 Agreement: By using the Platform, you agree to abide by these TOS and any additional guidelines or rules posted on the Platform.

1.2 Modification: Otakians reserves the right to modify, update, or change these TOS at any time. Any modifications will be effective immediately upon posting on the Platform. Your continued use of the Platform after such modifications constitutes your acceptance of the revised TOS.

+
2 - User Conduct

2.1 Eligibility: You must be at least 13 years of age to use the Platform. If you are under 13, you may only use the Platform with the consent and supervision of a parent or legal guardian.

2.2 Compliance: You agree to comply with all applicable laws, regulations, and these TOS when using the Platform. You will not use the Platform for any illegal, harmful, or unauthorized purposes.

2.3 Prohibited Content: You may not post, transmit, or share any content on the Platform that is unlawful, defamatory, obscene, offensive, or infringing upon the rights of others. This includes, but is not limited to, hate speech, harassment, and explicit or pornographic material.

2.4 User Responsibility: You are solely responsible for the content you post on the Platform. Otakians does not endorse or guarantee the accuracy, integrity, or quality of user-generated content.

+
3 - Intellectual Property

3.1 Ownership: Otakians and its licensors retain all rights, titles, and interests in and to the Platform, including all associated intellectual property rights. You agree not to use, reproduce, distribute, or create derivative works based on the Platform without prior written permission from Otakians.

3.2 User Content: By posting content on the Platform, you grant Otakians a non-exclusive, royalty-free, worldwide license to use, modify, adapt, reproduce, distribute, and display such content for the purpose of operating and improving the Platform.

+
4 - Privacy

4.1 Collection of Information: Otakians collects and stores information as described in the Privacy Policy. By using the Platform, you consent to the collection, use, and storage of your information as outlined in the Privacy Policy.

4.2 User Safety: While Otakians strives to provide a safe platform, you acknowledge and accept that interactions with other users are at your own risk. Otakians is not responsible for the actions or behavior of its users.

+
5 - Limitation of Liability

5.1 Disclaimer: The Platform is provided on an "as is" and "as available" basis, without warranties of any kind, whether express or implied. Otakians disclaims all warranties, including but not limited to merchantability, fitness for a particular purpose, and non-infringement.

5.2 Indemnification: You agree to indemnify, defend, and hold Otakians and its affiliates harmless from any claims, liabilities, damages, losses, or expenses arising out of your use of the Platform or violation of these TOS.

5.3 Limitation of Liability: In no event shall Otakians be liable for any indirect, incidental, special, consequential, or punitive damages, whether arising from the use of the Platform or any content therein.

+
6 - Termination

6.1 Termination: Otakians reserves the right to suspend, terminate, or restrict your access to the Platform, in whole or in part, at any time and for any reason, without prior notice or liability. This includes the removal of any content you have posted on the Platform.

6.2 Effect of Termination: Upon termination of your access to the Platform, you will no longer have the right to use or access the Platform or any content therein. The provisions of these TOS that, by their nature, should survive termination (including, but not limited to, intellectual property rights, indemnification, and limitations of liability) shall continue to apply.

+
7 - Miscellaneous

7.1 Entire Agreement: These TOS constitute the entire agreement between you and Otakians regarding your use of the Platform, superseding any prior agreements or understandings.

7.2 Governing Law: These TOS shall be governed by and construed in accordance with the laws of Zina lands. Any legal action or proceeding arising out of or relating to these TOS shall be exclusively heard in the courts located within Zina lands.

7.3 Severability: If any provision of these TOS is deemed invalid or unenforceable, that provision will be deemed severable and shall not affect the validity and enforceability of the remaining provisions.

7.4 Waiver: The failure of Otakians to enforce any right or provision of these TOS shall not constitute a waiver of such right or provision unless acknowledged and agreed to in writing.

7.5 Contact: If you have any questions, concerns, or feedback regarding these TOS, please contact us at [Insert contact information].

By using the Otakians Platform, you acknowledge that you have read, understood, and agreed to these Terms of Service.

+
\ No newline at end of file diff --git a/Otakians/Program.cs b/Otakians/Program.cs index 2c5cb37..cd65a74 100644 --- a/Otakians/Program.cs +++ b/Otakians/Program.cs @@ -1,13 +1,26 @@ using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using MudBlazor.Services; +using Blazored.LocalStorage; using Otakians; +using System; +using System.Security.Cryptography; +using System.Text; -var builder = WebAssemblyHostBuilder.CreateDefault(args); -builder.RootComponents.Add("#app"); -builder.RootComponents.Add("head::after"); +internal class Program +{ + private static async Task Main(string[] args) + { + var builder = WebAssemblyHostBuilder.CreateDefault(args); + builder.RootComponents.Add("#app"); + builder.RootComponents.Add("head::after"); -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); -builder.Services.AddMudServices(); + builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); + builder.Services.AddMudServices(); + builder.Services.AddBlazoredLocalStorage(); // local storage + builder.Services.AddBlazoredLocalStorage(config => + config.JsonSerializerOptions.WriteIndented = true); // local storage -await builder.Build().RunAsync(); + await builder.Build().RunAsync(); + } +} \ No newline at end of file diff --git a/Otakians/_Imports.razor b/Otakians/_Imports.razor index 9ce3f84..96f9c5f 100644 --- a/Otakians/_Imports.razor +++ b/Otakians/_Imports.razor @@ -1,6 +1,7 @@ @using System.Net.Http @using System.Net.Http.Json @using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.WebAssembly.Http @using Microsoft.JSInterop