aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_pages/register-page
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app/_pages/register-page')
-rw-r--r--frontend/src/app/_pages/register-page/register-page.component.html80
-rw-r--r--frontend/src/app/_pages/register-page/register-page.component.ts126
2 files changed, 0 insertions, 206 deletions
diff --git a/frontend/src/app/_pages/register-page/register-page.component.html b/frontend/src/app/_pages/register-page/register-page.component.html
index f8ae046e..e69de29b 100644
--- a/frontend/src/app/_pages/register-page/register-page.component.html
+++ b/frontend/src/app/_pages/register-page/register-page.component.html
@@ -1,80 +0,0 @@
-<div style="min-height: 100vh; position: relative;">
-
- <!-- TODO <app-navbar [activeNav]="'register'"></app-navbar>-->
-
- <div class="container" style="margin-top: 50px;">
- <div class="text-black">
- <div class="row justify-content-center">
- <div class="col-8 bg-white border rounded-3 shadow-sm p-5">
- <p class="text-center h2 fw-bold mb-5 mx-1 mx-md-4">Registracija</p>
-
- <form class="mx-1 mx-md-4">
- <!--Ime-->
- <div class="row">
- <div class="col-6 p-2">
- <label class="form-label" for="firstName">Ime</label>
- <input type="text" id="firstName" class="form-control" [(ngModel)]="firstName" name="firstName">
- <p *ngIf="wrongFirstNameBool" class="small fw-bold text-danger">Unesite ispravno ime. (minimum 1, maksimum 30 karaktera)</p>
- </div>
- <!--Prezime-->
- <div class="col-6 p-2">
- <label class="form-label" for="lastName">Prezime</label>
- <input type="text" id="lastName" class="form-control" [(ngModel)]="lastName" name="lastName" />
- <p *ngIf="wrongLastNameBool" class="small fw-bold text-danger">Unesite ispravno prezime. (minimum 1, maksimum 30 karaktera)</p>
- </div>
- </div>
- <br>
-
- <div class="row">
- <!--Korisnicko ime-->
- <div class="col-6 p-2">
- <label class="form-label" for="nickName">Korisničko ime</label>
- <input type="text" id="nickName" class="form-control" [(ngModel)]="nickName" name="nickName" />
- <p *ngIf="wrongNickNameBool" class="small fw-bold text-danger">Unesite ispravno korisničko ime.</p>
- </div>
- <!--Email-->
- <div class="col-6 p-2">
- <label class="form-label" for="email">E-mail adresa</label>
- <input type="email" id="email" class="form-control" [(ngModel)]="email" name="email" />
- <p *ngIf="wrongEmailBool" class="small fw-bold text-danger">Unesite ispravnu e-mail adresu.</p>
- </div>
- </div>
- <br>
-
- <div class="row">
- <!-- Lozinka 1. -->
- <div class="col-6 p-2">
- <label class="form-label" for="pass1">Lozinka</label>
- <input type="password" id="pass1" class="form-control" [(ngModel)]="pass1" name="pass1" />
- <p *ngIf="wrongPass1Bool" class="small fw-bold text-danger">Lozinka se mora sastojati od najmanje 6 karaktera.</p>
- </div>
-
- <!-- Lozinka 2. -->
- <div class="col-6 p-2">
- <label class="form-label" for="pass2">Potvrdite lozinku</label>
- <input type="password" id="pass2" class="form-control" [(ngModel)]="pass2" name="pass2" />
- <p *ngIf="wrongPass2Bool" class="small fw-bold text-danger">Lozinke se ne podudaraju.</p>
- </div>
- </div>
-
- <br><br><br>
- <!--Dugme Registruj se-->
- <div class="d-flex justify-content-center mx-4 mb-3 mb-lg-4">
- <button type="button" class="btn btn-primary btn-lg" (click)="validation()">Registrujte se</button>
- </div>
-
- <div class="form-check d-flex justify-content-center mb-5">
- <label class="form-check-label" class="small fw-bold mt-2 pt-1 mb-0" for="form2Example3">
- Već imate kreiran nalog?
- <a routerLink="/login" class="link-danger">Prijavite se</a>
- </label>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
-
- <!-- TODO <app-footer></app-footer> -->
-
-</div> \ No newline at end of file
diff --git a/frontend/src/app/_pages/register-page/register-page.component.ts b/frontend/src/app/_pages/register-page/register-page.component.ts
index 712fc55e..3add63a4 100644
--- a/frontend/src/app/_pages/register-page/register-page.component.ts
+++ b/frontend/src/app/_pages/register-page/register-page.component.ts
@@ -8,133 +8,7 @@ import { AuthService } from 'src/app/_services/auth.service';
styleUrls: ['./register-page.component.css']
})
export class RegisterPageComponent implements OnInit {
- firstName: string = '';
- lastName: string = '';
- nickName: string = '';
- email: string = '';
- pass1: string = '';
- pass2: string = '';
-
- wrongFirstNameBool: boolean = false;
- wrongLastNameBool: boolean = false;
- wrongNickNameBool: boolean = false;
- wrongEmailBool: boolean = false;
- wrongPass1Bool: boolean = false;
- wrongPass2Bool: boolean = false;
-
- pattName: RegExp = /^[a-zA-ZšŠđĐčČćĆžŽ]+([ \-][a-zA-ZšŠđĐčČćĆžŽ]+)*$/;
- pattTwoSpaces: RegExp = / /;
- pattEmail: RegExp = /^[a-zA-Z0-9]+([\.\-\+][a-zA-Z0-9]+)*\@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$/;
- pattPassword: RegExp = /.{6,30}$/;
-
- constructor(
- private router: Router,
- private authService: AuthService,
- ) { }
ngOnInit(): void {
}
-
- isCorrectName(element: string): boolean {
- if (this.pattName.test(element) && !(this.pattTwoSpaces.test(element)) && (element.length >= 1 && element.length <= 30))
- return true;
- return false;
- }
- isCorrectEmail(element: string): boolean {
- if (this.pattEmail.test(element.toLowerCase()) && element.length <= 320)
- return true;
- return false;
- }
- isCorrectPassword(element: string): boolean {
- if (this.pattPassword.test(element))
- return true;
- return false;
- }
-
- firstNameValidation() {
- if (this.isCorrectName(this.firstName) == true) {
- this.wrongFirstNameBool = false;
- return;
- }
- (<HTMLSelectElement>document.getElementById('firstName')).focus();
- this.wrongFirstNameBool = true;
- }
- lastNameValidation() {
- if (this.isCorrectName(this.lastName) == true) {
- this.wrongLastNameBool = false;
- return;
- }
- (<HTMLSelectElement>document.getElementById('lastName')).focus();
- this.wrongLastNameBool = true;
- }
- nickNameValidation() {
- if (this.isCorrectName(this.nickName) == true) {
- this.wrongNickNameBool = false;
- return;
- }
- (<HTMLSelectElement>document.getElementById('nickName')).focus();
- this.wrongNickNameBool = true;
- }
- emailValidation() {
- if (this.isCorrectEmail(this.email) == true) {
- this.wrongEmailBool = false;
- return;
- }
- (<HTMLSelectElement>document.getElementById('email')).focus();
- this.wrongEmailBool = true;
- }
- passwordValidation() {
- if (this.isCorrectPassword(this.pass1) && this.isCorrectPassword(this.pass2) && this.pass1 == this.pass2) {
- this.wrongPass1Bool = false;
- this.wrongPass2Bool = false;
- return;
- }
- this.pass1 = ''; //brisi obe ukucane lozinke
- this.pass2 = '';
- (<HTMLSelectElement>document.getElementById('pass1')).focus();
- this.wrongPass1Bool = true;
- this.wrongPass2Bool = true;
- }
-
- validation() {
- this.firstName = this.firstName.trim();
- this.lastName = this.lastName.trim();
- this.nickName = this.nickName.trim();
- this.email = this.email.trim();
-
- this.firstNameValidation();
- this.lastNameValidation();
- //this.nickNameValidation();
- this.emailValidation();
- this.passwordValidation();
-
- if (!(this.wrongFirstNameBool || this.wrongLastNameBool || this.wrongNickNameBool ||
- this.wrongEmailBool || this.wrongPass1Bool || this.wrongPass2Bool)) { //sve ok, registruj ga
-
- let user = {
- firstName: this.firstName,
- lastName: this.lastName,
- username: this.nickName,
- password: this.pass1,
- email: this.email
- }
-
- this.authService.register(user)
- .subscribe(
- (response) => {
- console.log(response);
- if (response === 'User added')
- this.router.navigate(['/login']); //registracija uspesna, idi na login
- else if (response === 'Email Already Exists')
- alert('Nalog sa unetim email-om već postoji!');
- else if (response === 'Username Already Exists')
- alert('Nalog sa unetim korisnićkim imenom već postoji!');
- }
- );
- }
- }
-
-
-
-
}