Skip to content

Commit ed7051f

Browse files
committed
Merge branch 'feature/sign-in' into develop
2 parents 3e47a24 + 34c210d commit ed7051f

File tree

75 files changed

+109
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+109
-119
lines changed

src/app/features/_auth/auth-routing.module.ts src/app/+auth/auth-routing.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { RouterModule, Routes } from '@angular/router';
33
import { Path } from '@app/@core/enums';
44
import { ForgotPasswordEmailSentPage } from './pages/forgot-password-email-sent/forgot-password-email-sent.page';
55
import { ForgotPasswordPage } from './pages/forgot-password/forgot-password.page';
6-
import { LOGIN_ROUTE } from './pages/login/login.page.route';
76
import { PasswordResetFailedPage } from './pages/password-reset-failed/password-reset-failed.page';
87
import { PasswordResetSucceededPage } from './pages/password-reset-succeeded/password-reset-succeeded.page';
98
import { PasswordResetPage } from './pages/password-reset/password-reset.page';
9+
import { SIGN_IN_ROUTE } from './pages/sign-in/sign-in.page.route';
1010
import { SignUpPage } from './pages/sign-up/sign-up.page';
1111

1212
const routes: Routes = [
13-
LOGIN_ROUTE,
13+
SIGN_IN_ROUTE,
1414
{
1515
path: Path.SignUp,
1616
component: SignUpPage,

src/app/features/_auth/auth.module.ts src/app/+auth/auth.module.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@ import { CommonModule } from '@angular/common';
22
import { NgModule } from '@angular/core';
33
import { AuthRoutingModule } from './auth-routing.module';
44
import { ForgotPasswordFormComponent } from './components/forgot-password-form/forgot-password-form.component';
5-
import { LoginFormComponent } from './components/login-form/login-form.component';
65
import { PasswordResetFormComponent } from './components/password-reset-form/password-reset-form.component';
6+
import { SignInFormComponent } from './components/sign-in-form/sign-in-form.component';
77
import { SignUpFormComponent } from './components/sign-up-form/sign-up-form.component';
88
import { ForgotPasswordEmailSentPage } from './pages/forgot-password-email-sent/forgot-password-email-sent.page';
99
import { ForgotPasswordPage } from './pages/forgot-password/forgot-password.page';
10-
import { LoginPage } from './pages/login/login.page';
1110
import { PasswordResetFailedPage } from './pages/password-reset-failed/password-reset-failed.page';
1211
import { PasswordResetSucceededPage } from './pages/password-reset-succeeded/password-reset-succeeded.page';
1312
import { PasswordResetPage } from './pages/password-reset/password-reset.page';
13+
import { SignInPage } from './pages/sign-in/sign-in.page';
1414
import { SignUpPage } from './pages/sign-up/sign-up.page';
1515

1616
@NgModule({
1717
declarations: [
18-
LoginPage,
18+
SignInPage,
1919
SignUpPage,
2020
ForgotPasswordPage,
2121
ForgotPasswordEmailSentPage,
2222
PasswordResetPage,
2323
PasswordResetSucceededPage,
2424
PasswordResetFailedPage,
25-
LoginFormComponent,
25+
SignInFormComponent,
2626
SignUpFormComponent,
2727
ForgotPasswordFormComponent,
2828
PasswordResetFormComponent,
29+
SignInFormComponent,
2930
],
3031
imports: [CommonModule, AuthRoutingModule],
3132
})

src/app/features/_auth/components/login-form/login-form.component.html src/app/+auth/components/sign-in-form/sign-in-form.component.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<!-- card -->
2-
32
<div
43
class="z-10 flex flex-col justify-center w-full p-6 bg-transparent rounded-none sm:rounded sm:h-auto sm:bg-accent md:shadow-2xl"
54
>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { SignInFormComponent } from './sign-in-form.component';
4+
5+
describe('SignInFormComponent', () => {
6+
let component: SignInFormComponent;
7+
let fixture: ComponentFixture<SignInFormComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ SignInFormComponent ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(SignInFormComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

src/app/features/_auth/components/login-form/login-form.component.ts src/app/+auth/components/sign-in-form/sign-in-form.component.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import { Path } from '@app/@core/enums';
1010
import { User } from '@app/@core/shared/user';
1111

1212
@Component({
13-
selector: 'app-login-form',
14-
templateUrl: './login-form.component.html',
15-
styleUrls: ['./login-form.component.scss'],
13+
selector: 'app-sign-in-form',
14+
templateUrl: './sign-in-form.component.html',
15+
styleUrls: ['./sign-in-form.component.scss'],
1616
changeDetection: ChangeDetectionStrategy.OnPush,
1717
})
18-
export class LoginFormComponent implements OnInit {
18+
export class SignInFormComponent implements OnInit {
1919
@Input() errorMessage: string;
2020
@Input() loading: boolean;
2121

@@ -29,8 +29,8 @@ export class LoginFormComponent implements OnInit {
2929

3030
onClickSignIn() {
3131
const user: Partial<User> = {
32-
username: 'juanmesa2097',
33-
password: 'televition',
32+
username: '',
33+
password: '',
3434
};
3535
this.signIn.emit(user);
3636
}
File renamed without changes.

src/app/features/_auth/pages/login/login.page.html src/app/+auth/pages/sign-in/sign-in.page.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
<div class="container relative px-0 my-0 sm:my-auto">
3333
<!-- row -->
3434
<div class="max-w-full mx-auto sm:max-w-md">
35-
<!-- login form -->
36-
<app-login-form
35+
<!-- sign in form -->
36+
<app-sign-in-form
3737
[errorMessage]="errorMessage"
3838
[loading]="loading"
3939
(signIn)="onSignIn($event)"
40-
></app-login-form>
41-
<!-- login form end -->
40+
></app-sign-in-form>
41+
<!-- sign in form end -->
4242
</div>
4343
<!-- row end -->
4444
</div>

src/app/features/_auth/pages/login/login.page.route.ts src/app/+auth/pages/sign-in/sign-in.page.route.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Route } from '@angular/router';
22
import { Path } from '@app/@core/enums';
3-
import { LoginPage } from './login.page';
3+
import { SignInPage } from './sign-in.page';
44

5-
export const LOGIN_ROUTE: Route = {
6-
path: Path.Login,
7-
component: LoginPage,
5+
export const SIGN_IN_ROUTE: Route = {
6+
path: Path.SignIn,
7+
component: SignInPage,
88
data: {
9-
title: 'Login on Angular Boilerplate',
9+
title: 'Sign into Angular Boilerplate',
1010
description:
1111
'Start writing your business logic without any concern on architecture matters.',
1212
robots: 'index, follow',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { SignInPage } from './sign-in.page';
4+
5+
describe('SignInPage', () => {
6+
let component: SignInPage;
7+
let fixture: ComponentFixture<SignInPage>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ SignInPage ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(SignInPage);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

src/app/features/_auth/pages/login/login.page.ts src/app/+auth/pages/sign-in/sign-in.page.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { Component, OnInit } from '@angular/core';
22
import { ActivatedRoute, Router } from '@angular/router';
3+
import { AuthService } from '@app/+auth';
34
import { Path } from '@app/@core/enums';
45
import { User } from '@app/@core/shared/user';
5-
import { AuthService } from '../../shared/services/auth.service';
66

77
@Component({
8-
templateUrl: './login.page.html',
9-
styleUrls: ['./login.page.scss'],
8+
templateUrl: './sign-in.page.html',
9+
styleUrls: ['./sign-in.page.scss'],
1010
})
11-
export class LoginPage implements OnInit {
11+
export class SignInPage implements OnInit {
1212
returnUrl: string;
1313
errorMessage: string;
1414
loading = false;
@@ -28,7 +28,7 @@ export class LoginPage implements OnInit {
2828
async onSignIn(user: User) {
2929
this.loading = true;
3030
try {
31-
await this.authService.login(user).toPromise();
31+
await this.authService.signIn(user).toPromise();
3232
this.router.navigate([this.returnUrl]);
3333
} catch (err) {
3434
const message = [401, 403].includes(err.status)

src/app/+auth/pages/sign-up/sign-up.page.scss

Whitespace-only changes.
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { SignInResult } from './sign-in-result.interface';
2+
export { Token } from './token.interface';
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { User } from '@core/shared/user';
22
import { Token } from '.';
33

4-
export interface LoginResult {
4+
export interface SignInResult {
55
user: User;
66
token: Token;
77
}

src/app/features/_auth/shared/services/auth.service.ts src/app/+auth/shared/services/auth.service.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { User } from '@core/shared/user';
55
import { environment } from '@environments/environment';
66
import { BehaviorSubject, Observable } from 'rxjs';
77
import { map } from 'rxjs/operators';
8-
import { LoginResult, Token } from '../interfaces';
8+
import { SignInResult, Token } from '../interfaces';
99

1010
@Injectable({
1111
providedIn: 'root',
1212
})
13-
export class AuthService extends GenericHttpService<User | LoginResult> {
13+
export class AuthService extends GenericHttpService<User | SignInResult> {
1414
private readonly USER_ITEM = '_user';
1515
private readonly TOKEN_ITEM = '_token';
1616

@@ -37,9 +37,9 @@ export class AuthService extends GenericHttpService<User | LoginResult> {
3737
return !!(user && token);
3838
}
3939

40-
login({ username, password }: User): Observable<LoginResult> {
41-
return super.post({ username, password }, 'login').pipe(
42-
map((result: LoginResult) => {
40+
signIn({ username, password }: User): Observable<SignInResult> {
41+
return super.post({ username, password }, 'sign-in').pipe(
42+
map((result: SignInResult) => {
4343
const { user, token } = result;
4444
this._saveUser(user);
4545
this._saveToken(token);
@@ -49,8 +49,8 @@ export class AuthService extends GenericHttpService<User | LoginResult> {
4949
);
5050
}
5151

52-
register(user: User): Observable<User> {
53-
return super.post(user, 'register') as Observable<User>;
52+
signUp(user: User): Observable<User> {
53+
return super.post(user, 'sign-up') as Observable<User>;
5454
}
5555

5656
beginPasswordReset(email: string) {

src/app/@core/enums/path.enum.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export enum Path {
66

77
// Auth
88
Auth = '',
9-
Login = 'login',
9+
SignIn = 'sign-in',
1010
SignUp = 'sign-up',
1111
ForgotPassword = 'forgot-password',
1212
ForgotPasswordEmailSent = 'forgot-password-email-sent',

src/app/@core/guards/auth.guard.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
RouterStateSnapshot,
77
UrlTree,
88
} from '@angular/router';
9-
import { AuthService } from '@app/features/_auth';
9+
import { AuthService } from '@app/+auth';
1010
import { Observable } from 'rxjs';
1111
import { Path } from '../enums';
1212

@@ -30,8 +30,8 @@ export class AuthGuard implements CanActivate {
3030
return true;
3131
}
3232

33-
// if not logged in redirects to login page with the return url
34-
this.router.navigate([`/${Path.Login}`], {
33+
// if not logged in redirects to sign-in page with the return url
34+
this.router.navigate([`/${Path.SignIn}`], {
3535
queryParams: { returnUrl: state.url },
3636
});
3737

src/app/@core/guards/no-auth.guard.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
RouterStateSnapshot,
77
UrlTree,
88
} from '@angular/router';
9-
import { AuthService } from '@app/features/_auth';
9+
import { AuthService } from '@app/+auth';
1010
import { Observable } from 'rxjs';
1111
import { Path } from '../enums';
1212

src/app/@core/guards/role.guard.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
RouterStateSnapshot,
77
UrlTree,
88
} from '@angular/router';
9-
import { AuthService } from '@app/features/_auth';
9+
import { AuthService } from '@app/+auth';
1010
import { Observable } from 'rxjs';
1111
import { RoleList } from '../shared/role';
1212

src/app/@core/interceptors/jwt.interceptor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
HttpRequest,
66
} from '@angular/common/http';
77
import { Injectable } from '@angular/core';
8-
import { AuthService } from '@app/features/_auth';
8+
import { AuthService } from '@app/+auth';
99
import { environment } from '@environments/environment';
1010
import { Observable } from 'rxjs';
1111

src/app/@core/interceptors/server-error.interceptor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '@angular/common/http';
88
import { Injectable } from '@angular/core';
99
import { Router } from '@angular/router';
10-
import { AuthService } from '@app/features/_auth';
10+
import { AuthService } from '@app/+auth';
1111
import { Observable, throwError } from 'rxjs';
1212
import { catchError } from 'rxjs/operators';
1313
import { Path } from '../enums';
@@ -24,7 +24,7 @@ export class ServerErrorInterceptor implements HttpInterceptor {
2424
catchError((error: HttpErrorResponse) => {
2525
if ([401, 403].includes(error.status)) {
2626
this.authService.logout();
27-
this.router.navigateByUrl(Path.Login);
27+
this.router.navigateByUrl(Path.SignIn);
2828
return throwError(error);
2929
} else if (error.status === 500) {
3030
this.router.navigateByUrl('/internal-server-error');

src/app/app-routing.module.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { NgModule } from '@angular/core';
22
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
3-
import { NotFoundPage } from '@public/pages/not-found/not-found.page';
43
import { Path } from './@core/enums/path.enum';
54
import { AuthGuard, NoAuthGuard } from './@core/guards';
5+
import { NotFoundPage } from './public/pages/not-found/not-found.page';
66

77
const routes: Routes = [
88
// ===== Uncomment if Path.Home is different from empty =====
@@ -12,15 +12,14 @@ const routes: Routes = [
1212
{
1313
path: '',
1414
loadChildren: () =>
15-
import('@public/public.module').then((m) => m.PublicModule),
15+
import('./public/public.module').then((m) => m.PublicModule),
1616
},
1717

1818
// Auth
1919
{
2020
path: Path.Auth,
2121
canActivate: [NoAuthGuard],
22-
loadChildren: () =>
23-
import('@features/_auth/auth.module').then((m) => m.AuthModule),
22+
loadChildren: () => import('./+auth/auth.module').then((m) => m.AuthModule),
2423
},
2524

2625
// App
@@ -36,9 +35,7 @@ const routes: Routes = [
3635
{
3736
path: Path.Dashboard,
3837
loadChildren: () =>
39-
import('@features/dashboard/dashboard.module').then(
40-
(m) => m.DashboardModule
41-
),
38+
import('./dashboard/dashboard.module').then((m) => m.DashboardModule),
4239
},
4340
],
4441
},
@@ -52,7 +49,10 @@ const routes: Routes = [
5249

5350
@NgModule({
5451
imports: [
55-
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules, relativeLinkResolution: 'legacy' }),
52+
RouterModule.forRoot(routes, {
53+
preloadingStrategy: PreloadAllModules,
54+
relativeLinkResolution: 'legacy',
55+
}),
5656
],
5757
exports: [RouterModule],
5858
})

src/app/app.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Component, OnInit } from '@angular/core';
22
import { Router } from '@angular/router';
33
import { Observable } from 'rxjs';
4+
import { AuthService } from './+auth';
45
import { Path } from './@core/enums';
56
import { SeoService } from './@core/services';
6-
import { AuthService } from './features/_auth';
77
@Component({
88
selector: 'app-root',
99
templateUrl: './app.component.html',
@@ -26,6 +26,6 @@ export class AppComponent implements OnInit {
2626

2727
onLogout() {
2828
this.authService.logout();
29-
this.router.navigate([Path.Login]);
29+
this.router.navigate([Path.SignIn]);
3030
}
3131
}

src/app/dashboard/pages/dashboard/dashboard.page.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)