aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-03-25 18:07:45 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-03-25 18:07:45 -0400
commitb0369f8b5e50eaec22c9178748f57dde6912d383 (patch)
tree35321024e74b71f11bda4ecc30de44843f28a838
parent5f03e80712f7a18370b5118fde5327bde1b6fbbf (diff)
downloadJellySolutions-b0369f8b5e50eaec22c9178748f57dde6912d383.tar.gz
JellySolutions-b0369f8b5e50eaec22c9178748f57dde6912d383.tar.bz2
JellySolutions-b0369f8b5e50eaec22c9178748f57dde6912d383.zip
Created signup component and implemented some functionality. Did not finish implementing color bar and error messages.
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java2
-rw-r--r--ufund-ui/src/app/app-routing.module.ts4
-rw-r--r--ufund-ui/src/app/app.module.ts2
-rw-r--r--ufund-ui/src/app/components/signup/signup.component.css16
-rw-r--r--ufund-ui/src/app/components/signup/signup.component.html7
-rw-r--r--ufund-ui/src/app/components/signup/signup.component.ts118
6 files changed, 147 insertions, 2 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
index e62d5ab..d2029ed 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
@@ -173,7 +173,7 @@ public class CupboardController {
/**
* Checks out a need by checkoutAmount
*
- * @param data JSON object with paramters needID and amount
+ * @param data JSON object with parameters needID and amount
* @param key Key used to authenticate user
* @return OK if successful, other statuses if failure
*/
diff --git a/ufund-ui/src/app/app-routing.module.ts b/ufund-ui/src/app/app-routing.module.ts
index 4b76654..a6ea806 100644
--- a/ufund-ui/src/app/app-routing.module.ts
+++ b/ufund-ui/src/app/app-routing.module.ts
@@ -6,6 +6,7 @@ import {LoginComponent} from './components/login/login.component';
import {HomePageComponent} from './components/home-page/home-page.component';
import {FundingBasketComponent} from './components/funding-basket/funding-basket.component';
import {NeedPageComponent} from './components/need-page/need-page.component';
+import {SignupComponent} from './components/signup/signup.component';
const routes: Routes = [
{path: '', component: HomePageComponent},
@@ -13,7 +14,8 @@ const routes: Routes = [
{path: 'cupboard', component: CupboardComponent},
{path: 'dashboard', component: DashboardComponent},
{path: 'basket', component: FundingBasketComponent},
- {path: 'need/:id', component: NeedPageComponent}
+ {path: 'need/:id', component: NeedPageComponent},
+ {path: 'signup', component: SignupComponent},
];
@NgModule({
diff --git a/ufund-ui/src/app/app.module.ts b/ufund-ui/src/app/app.module.ts
index 9f525fe..156ef5f 100644
--- a/ufund-ui/src/app/app.module.ts
+++ b/ufund-ui/src/app/app.module.ts
@@ -14,6 +14,7 @@ import {RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
import {DashboardComponent} from './components/dashboard/dashboard.component';
import {CommonModule} from '@angular/common';
import {LoginComponent} from './components/login/login.component';
+import { SignupComponent } from './components/signup/signup.component';
@NgModule({
declarations: [
@@ -25,6 +26,7 @@ import {LoginComponent} from './components/login/login.component';
NeedListComponent,
DashboardComponent,
LoginComponent,
+ SignupComponent,
],
imports: [
BrowserModule,
diff --git a/ufund-ui/src/app/components/signup/signup.component.css b/ufund-ui/src/app/components/signup/signup.component.css
new file mode 100644
index 0000000..2a10016
--- /dev/null
+++ b/ufund-ui/src/app/components/signup/signup.component.css
@@ -0,0 +1,16 @@
+:host, .border {
+ display: flex;
+ flex-direction: column;
+ max-width: 300px;
+ gap: 5px
+}
+
+.border {
+ border-style: solid;
+ border-width: 1px;
+ padding: 10px;
+ margin: 10px;
+ position: absolute;
+ background-color: white;
+ box-shadow: 0 0 10px 10px black;
+}
diff --git a/ufund-ui/src/app/components/signup/signup.component.html b/ufund-ui/src/app/components/signup/signup.component.html
new file mode 100644
index 0000000..742b8cf
--- /dev/null
+++ b/ufund-ui/src/app/components/signup/signup.component.html
@@ -0,0 +1,7 @@
+<p>Signup:</p>
+<input placeholder="Username" type="text" #username>
+<input placeholder="Password" type="password" (input)="checkPasswordStrength(password.value)" #password>
+<button type="button" (click)="signup(username.value, password.value)">Create Account</button>
+<span *ngIf="statusText">{{statusText | async}}</span>
+<span *ngIf="strength">{{strength | async}}</span>
+<span *ngIf="showSuccessMessage | async">Account created <a routerLink="/login">Proceed to login</a></span>
diff --git a/ufund-ui/src/app/components/signup/signup.component.ts b/ufund-ui/src/app/components/signup/signup.component.ts
new file mode 100644
index 0000000..48c6387
--- /dev/null
+++ b/ufund-ui/src/app/components/signup/signup.component.ts
@@ -0,0 +1,118 @@
+import { Component } from '@angular/core';
+import {UsersService} from '../../services/users.service';
+import {Router} from '@angular/router';
+import {BehaviorSubject} from 'rxjs';
+
+@Component({
+ selector: 'app-signup',
+ standalone: false,
+ templateUrl: './signup.component.html',
+ styleUrl: './signup.component.css'
+})
+export class SignupComponent {
+
+ protected statusText = new BehaviorSubject("")
+ protected showSuccessMessage = new BehaviorSubject(false)
+ protected passwordStrength = new BehaviorSubject("")
+ protected strength = new BehaviorSubject(0)
+
+ constructor(
+ protected usersService: UsersService,
+ protected router: Router,
+ ) {}
+
+ signup(username: string | null, password: string | null) {
+ console.log(`attempting to sign up with ${username} ${password}`)
+ if (!username || !password) {
+ return;
+ }
+
+ this.usersService.createUser(username, password).then(() => {
+ this.showSuccessMessage.next(true);
+ }).catch(ex => {
+ this.statusText.next("Unable to create account: " + friendlyHttpStatus[ex.status])
+ console.log(ex)
+ })
+ }
+
+ checkPasswordStrength(password: string) {
+ this.statusText.next("")
+ if (password.match(/[^!-~]/g)) {
+ this.statusText.next("Invalid characters")
+ return
+ }
+
+ let strength = 0;
+ if (password.length > 6) {
+ strength++
+ console.log("Long")
+ }
+ if (password.length > 12) {
+ strength++
+ console.log("Longer")
+ }
+ if (password.match(/[a-z]/g)) {
+ strength++
+ console.log("a")
+ }
+ if (password.match(/[0-9]/g)) {
+ strength++
+ console.log("0")
+ }
+ if (password.match(/[A-Z]/g)) {
+ strength++
+ console.log("A")
+ }
+ if (password.match(/[!-/]/g)) {
+ strength++
+ console.log("!")
+ }
+
+ this.strength.next(strength)
+ }
+
+}
+
+let friendlyHttpStatus: {[key: number]: string} = {
+ 200: 'OK',
+ 201: 'Created',
+ 202: 'Accepted',
+ 203: 'Non-Authoritative Information',
+ 204: 'No Content',
+ 205: 'Reset Content',
+ 206: 'Partial Content',
+ 300: 'Multiple Choices',
+ 301: 'Moved Permanently',
+ 302: 'Found',
+ 303: 'See Other',
+ 304: 'Not Modified',
+ 305: 'Use Proxy',
+ 306: 'Unused',
+ 307: 'Temporary Redirect',
+ 400: 'Bad Request',
+ 401: 'Unauthorized',
+ 402: 'Payment Required',
+ 403: 'Forbidden',
+ 404: 'Not Found',
+ 405: 'Method Not Allowed',
+ 406: 'Not Acceptable',
+ 407: 'Proxy Authentication Required',
+ 408: 'Request Timeout',
+ 409: 'Conflict',
+ 410: 'Gone',
+ 411: 'Length Required',
+ 412: 'Precondition Required',
+ 413: 'Request Entry Too Large',
+ 414: 'Request-URI Too Long',
+ 415: 'Unsupported Media Type',
+ 416: 'Requested Range Not Satisfiable',
+ 417: 'Expectation Failed',
+ 418: 'I\'m a teapot',
+ 429: 'Too Many Requests',
+ 500: 'Internal Server Error',
+ 501: 'Not Implemented',
+ 502: 'Bad Gateway',
+ 503: 'Service Unavailable',
+ 504: 'Gateway Timeout',
+ 505: 'HTTP Version Not Supported',
+};