Skip to content

Commit

Permalink
chore: bumps version
Browse files Browse the repository at this point in the history
  • Loading branch information
rustygreen committed Mar 1, 2024
1 parent 72d2063 commit 2fc9f5e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 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.8 (2024-03-01)

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

## 1.0.0-rc.7 (2024-02-29)


Expand Down
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.7",
"version": "1.0.0-rc.8",
"author": "Rusty Green <me@rusty.green>",
"contributors": [
"Rusty Green <me@rusty.green>"
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.7",
"version": "1.0.0-rc.8",
"author": "Rusty Green <me@rusty.green>",
"contributors": [
"Rusty Green <me@rusty.green>"
Expand Down
4 changes: 3 additions & 1 deletion libs/core/src/lib/auth-guard/is-logged-in.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import { SupabaseConfig } from '../supabase-config';
import { LogService } from '../logging/log.service';
import { SupabaseService } from '../supabase.service';

export const IsLoggedIn: CanActivateFn = (
export const IsLoggedIn: CanActivateFn = async (
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
) => {
const log = inject(LogService);
const supabase = inject(SupabaseService);

await supabase.clientReady;
const loggedIn = supabase.isLoggedIn;

if (!loggedIn) {
Expand Down
24 changes: 18 additions & 6 deletions libs/core/src/lib/supabase.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ import { LogService } from './logging/log.service';
})
export class SupabaseService {
client!: SupabaseClient;
authChange = new Subject<AuthChangeEvent>();
session = new BehaviorSubject<Session | null>(null);
user = new BehaviorSubject<User | null>(null);
displayName = new BehaviorSubject<string>('');
loggedIn = new BehaviorSubject<boolean>(false);
readonly authChange = new Subject<AuthChangeEvent>();
readonly initialized = new BehaviorSubject<boolean>(false);
readonly session = new BehaviorSubject<Session | null>(null);
readonly user = new BehaviorSubject<User | null>(null);
readonly displayName = new BehaviorSubject<string>('');
readonly loggedIn = new BehaviorSubject<boolean>(false);

readonly clientReady: Promise<SupabaseClient>;

get isLoggedIn(): boolean {
return this.loggedIn.value;
Expand All @@ -44,6 +47,13 @@ export class SupabaseService {
this.displayName.next(name);
});

this.clientReady = firstValueFrom(
this.initialized.pipe(
filter(Boolean),
map(() => this.client)
)
);

this.config.api.subscribe(() => this.setup());
}

Expand Down Expand Up @@ -77,7 +87,9 @@ export class SupabaseService {
private setAuthState(event: AuthChangeEvent): void {
this.log.info(`Auth state change: '${event}'`);
this.authChange.next(event);
if (event === 'SIGNED_IN') {
if (event === 'INITIAL_SESSION') {
this.initialized.next(true);
} else if (event === 'SIGNED_IN') {
this.tryGetSession();
} else if (event === 'SIGNED_OUT') {
this.setStateForSignedOut();
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.7",
"version": "1.0.0-rc.8",
"author": "Rusty Green <me@rusty.green>",
"contributors": [
"Rusty Green <me@rusty.green>"
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.7",
"version": "1.0.0-rc.8",
"author": "Rusty Green <me@rusty.green>",
"contributors": [
"Rusty Green <me@rusty.green>"
Expand Down

0 comments on commit 2fc9f5e

Please sign in to comment.