Skip to content

Commit

Permalink
chore: adds reset password to login
Browse files Browse the repository at this point in the history
  • Loading branch information
rustygreen committed Feb 10, 2024
1 parent 0313a4e commit b2c4d89
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0-rc.3 (2024-02-10)

This was a version bump only, there were no code changes.

## 1.0.0-rc.2 (2024-02-10)

This was a version bump only, there were no code changes.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export const appConfig: ApplicationConfig = {

![Login Component](/assets/primeng-login.png)

![Login Message](/assets/primeng-login-message.png)

### Register Component

![Register Component](/assets/primeng-register.png)
Expand All @@ -148,6 +150,8 @@ export const appConfig: ApplicationConfig = {

![Reset Password Component](/assets/primeng-reset-password.png)

![Reset Password Message](/assets/primeng-reset-password-message.png)

### Set Password Component

![Set Password Component](/assets/primeng-set-password.png)
Expand Down
5 changes: 0 additions & 5 deletions apps/demo/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ export const appConfig: ApplicationConfig = {
apiUrl: 'https://dzyrspsuxgieqnvgvryp.supabase.co',
apiKey:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR6eXJzcHN1eGdpZXFudmd2cnlwIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTQyMjQ5MDEsImV4cCI6MjAwOTgwMDkwMX0.d8Qqa07RrjW3OSAjSnlubYCXSiHJWW55y9sLN-Rjc6w',
routes: {
main: '/',
setPassword: '/set-password',
},
login: {
socials: ALL_SOCIAL_LOGINS,
// onSocialLogin: ()=>
},
logging: {
logLevel: LogLevel.Debug,
Expand Down
Binary file added assets/primeng-login-message.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/primeng-reset-password-message.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion libs/bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ng-supabase/bootstrap",
"version": "1.0.0-rc.2",
"version": "1.0.0-rc.3",
"author": "Rusty Green <[email protected]>",
"contributors": [
"Rusty Green <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion libs/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ng-supabase/core",
"version": "1.0.0-rc.2",
"version": "1.0.0-rc.3",
"author": "Rusty Green <[email protected]>",
"contributors": [
"Rusty Green <[email protected]>"
Expand Down
2 changes: 2 additions & 0 deletions libs/core/src/lib/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class LoginComponent implements OnInit {
@Input() redirectTo = '';
@Input() rememberMe: boolean | undefined;

forgotPassword = false;
wait: WaitMessage | null = null;
loggingIn = new Subject<boolean>();
errorMessage = new Subject<string>();
Expand Down Expand Up @@ -101,6 +102,7 @@ export class LoginComponent implements OnInit {

showForgotPassword(event?: MouseEvent): void {
event?.preventDefault();
this.forgotPassword = true;
}

login(): void {
Expand Down
10 changes: 8 additions & 2 deletions libs/core/src/lib/reset-password/reset-password.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
signal,
Component,
ChangeDetectionStrategy,
OnInit,
} from '@angular/core';
import {
FormGroup,
Expand All @@ -29,7 +30,7 @@ import { SupabaseConfig } from '../supabase-config';
styleUrl: './reset-password.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ResetPasswordComponent {
export class ResetPasswordComponent implements OnInit {
@Input() title = 'Reset Password';
@Input() email = '';
/**
Expand All @@ -49,7 +50,7 @@ export class ResetPasswordComponent {
readonly errorMessage = signal('');
readonly sendingReset = signal(false);
readonly wait = signal<WaitMessage | null>(null);
readonly form: FormGroup = new FormGroup({
readonly form = new FormGroup({
email: new FormControl('', [Validators.required]),
});

Expand All @@ -60,6 +61,11 @@ export class ResetPasswordComponent {
private readonly routeService: RouteService
) {}

ngOnInit(): void {
this.title = this.title ?? this.config.login.title;
this.form.controls.email.setValue(this.email);
}

async resetPassword(): Promise<void> {
if (this.form.invalid) {
return;
Expand Down
16 changes: 9 additions & 7 deletions libs/core/src/lib/supabase-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import {
SocialLoginItem,
} from './login/social-login';

export const DEFAULT_ROUTES: ComponentRoutes = {
main: '/',
login: '/login',
register: '/register',
setPassword: '/set-password',
resetPassword: '/reset-password',
};

export interface SupabaseConfigProperties {
apiUrl: string;
apiKey: string;
Expand Down Expand Up @@ -102,13 +110,7 @@ export class SupabaseConfig {
logging?: LogConfig;
mainRoute = '/';
setPassword: SetPasswordConfig;
routes: ComponentRoutes = {
main: '/',
login: '/login',
register: '/register',
setPassword: '/set-password',
resetPassword: '/reset-password',
};
routes: ComponentRoutes = DEFAULT_ROUTES;

constructor(init: SupabaseConfigProperties) {
Object.assign(this.routes, init.routes);
Expand Down
2 changes: 1 addition & 1 deletion libs/material/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ng-supabase/material",
"version": "1.0.0-rc.2",
"version": "1.0.0-rc.3",
"author": "Rusty Green <[email protected]>",
"contributors": [
"Rusty Green <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion libs/primeng/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ng-supabase/primeng",
"version": "1.0.0-rc.2",
"version": "1.0.0-rc.3",
"author": "Rusty Green <[email protected]>",
"contributors": [
"Rusty Green <[email protected]>"
Expand Down
4 changes: 4 additions & 0 deletions libs/primeng/src/lib/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ <h4>Logging in. Please wait...</h4>
</div>
</p-fieldset>

} @else if(forgotPassword) {
<supabase-reset-password
[email]="form.value.email || ''"
></supabase-reset-password>
} @else {
<!-- Login form -->
<form [formGroup]="form" (ngSubmit)="login()">
Expand Down
2 changes: 2 additions & 0 deletions libs/primeng/src/lib/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { LoginComponent as CoreLoginComponent } from '@ng-supabase/core';

// Local.
import { LoadingOverlayComponent } from '../loading-overlay/loading-overlay.component';
import { ResetPasswordComponent } from '../reset-password/reset-password.component';

@Component({
selector: 'supabase-login',
Expand All @@ -40,6 +41,7 @@ import { LoadingOverlayComponent } from '../loading-overlay/loading-overlay.comp
FieldsetModule,
InputTextModule,
ReactiveFormsModule,
ResetPasswordComponent,
LoadingOverlayComponent,
],
templateUrl: './login.component.html',
Expand Down

0 comments on commit b2c4d89

Please sign in to comment.