added svcapi ui and camunda code
[it/otf.git] / otf-frontend / client / src / app / signup / signup.component.ts
diff --git a/otf-frontend/client/src/app/signup/signup.component.ts b/otf-frontend/client/src/app/signup/signup.component.ts
new file mode 100644 (file)
index 0000000..85893e9
--- /dev/null
@@ -0,0 +1,102 @@
+/*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
+#                                                                              #\r
+#   Licensed under the Apache License, Version 2.0 (the "License");            #\r
+#   you may not use this file except in compliance with the License.           #\r
+#   You may obtain a copy of the License at                                    #\r
+#                                                                              #\r
+#       http://www.apache.org/licenses/LICENSE-2.0                             #\r
+#                                                                              #\r
+#   Unless required by applicable law or agreed to in writing, software        #\r
+#   distributed under the License is distributed on an "AS IS" BASIS,          #\r
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
+#   See the License for the specific language governing permissions and        #\r
+#   limitations under the License.                                             #\r
+##############################################################################*/\r
+\r
+\r
+import { Component, OnInit } from '@angular/core';\r
+import { routerTransition } from '../router.animations';\r
+import { HttpClient } from '@angular/common/http';\r
+import { AppGlobals } from '../app.global';\r
+import { UserService } from '../shared/services/user.service';\r
+import { Router } from '@angular/router';\r
+import { User } from '../shared/models/user.model';\r
+import { MatDialog } from '@angular/material';\r
+import { AlertModalComponent } from '../shared/modules/alert-modal/alert-modal.component';\r
+import { AuthService } from '../shared/services/auth.service';\r
+\r
+\r
+@Component({\r
+    selector: 'app-signup',\r
+    templateUrl: './signup.component.html',\r
+    styleUrls: ['./signup.component.scss'],\r
+    animations: [routerTransition()]\r
+})\r
+export class SignupComponent implements OnInit {\r
+    public user = {\r
+        password: null,\r
+        firstName: null,\r
+        lastName: null,\r
+        email: null\r
+    };\r
+    public passwordConfirm;\r
+\r
+    constructor(public router: Router,\r
+        private auth: AuthService,\r
+        public dialog: MatDialog\r
+        ) {\r
+           \r
+        }\r
+\r
+    ngOnInit() {\r
+        \r
+    }\r
+\r
+    register(){\r
+        // let body  = {\r
+        //     firstName: this.user.firstName,\r
+        //     lastName: this.user.lastName,\r
+        //     email: this.user.email,\r
+        //     password: this.user.password\r
+        // };\r
+        \r
+        if(this.user.password != this.passwordConfirm){\r
+            const dialogRef = this.dialog.open(AlertModalComponent, {\r
+                data:{\r
+                    type: "Alert",\r
+                    message: "Passwords must match!"\r
+                }\r
+\r
+            });\r
+            \r
+            return;\r
+        }\r
+\r
+        this.auth.register(this.user) \r
+            .subscribe(\r
+                (res) => {\r
+                    const r = this.dialog.open(AlertModalComponent, {\r
+                        data: {\r
+                            type: "Alert",\r
+                            message: "Check your email to verify your account."\r
+                        }\r
+                    });\r
+\r
+                    r.afterClosed().subscribe(res => {\r
+                        this.router.navigateByUrl('/login');\r
+                    })\r
+                      \r
+                },\r
+                (err) => {\r
+                    this.dialog.open(AlertModalComponent, {\r
+                        data:{\r
+                            type: "Alert",\r
+                            message: err\r
+                        }\r
+                    });\r
+                }\r
+            );\r
+        \r
+        \r
+    }\r
+}\r