@progalaxyelabs/ngx-stonescriptphp-client 1.18.0 → 1.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -74,6 +74,37 @@ authProviders: {
|
|
|
74
74
|
|
|
75
75
|
See [Configuration](#configuration) and [AUTH-PROVIDER-CONFIG.md](AUTH-PROVIDER-CONFIG.md) for details.
|
|
76
76
|
|
|
77
|
+
### Accessing User Info
|
|
78
|
+
|
|
79
|
+
After login or registration, the library stores the authenticated user. Access it in any component:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { AuthService, User } from '@progalaxyelabs/ngx-stonescriptphp-client';
|
|
83
|
+
|
|
84
|
+
@Component({ ... })
|
|
85
|
+
export class MyComponent {
|
|
86
|
+
constructor(private authService: AuthService) {}
|
|
87
|
+
|
|
88
|
+
ngOnInit() {
|
|
89
|
+
// Snapshot — current user or null if not authenticated
|
|
90
|
+
const user: User | null = this.authService.getCurrentUser();
|
|
91
|
+
if (user) {
|
|
92
|
+
console.log(user.display_name); // "John Doe"
|
|
93
|
+
console.log(user.email); // "john@example.com"
|
|
94
|
+
console.log(user.photo_url); // avatar URL (optional)
|
|
95
|
+
console.log(user.is_email_verified);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Reactive — emits on login, logout, and token refresh
|
|
99
|
+
this.authService.user$.subscribe(user => {
|
|
100
|
+
// user is User | null
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The `User` object is persisted in localStorage and restored on page refresh. It is populated from the auth service API response (not from the JWT token).
|
|
107
|
+
|
|
77
108
|
📖 **Documentation**: [CHANGELOG](docs/CHANGELOG.md) | [Auth Compatibility](docs/AUTH_COMPATIBILITY.md) | [Provider Config](AUTH-PROVIDER-CONFIG.md) | [Modal Auth Spec](MODAL-AUTH-SPEC.md) | [Multi-Auth Server](MULTI-AUTH-SERVER.md)
|
|
78
109
|
|
|
79
110
|
---
|
|
@@ -844,7 +844,7 @@ class ProgalaxyElabsAuth {
|
|
|
844
844
|
isNewIdentity: true,
|
|
845
845
|
authMethod: data.auth_method,
|
|
846
846
|
oauthProvider: data.oauth_provider,
|
|
847
|
-
|
|
847
|
+
user: this.toUser(data.identity),
|
|
848
848
|
};
|
|
849
849
|
}
|
|
850
850
|
// Multi-tenant selection required
|
|
@@ -2046,12 +2046,16 @@ class TenantLoginComponent {
|
|
|
2046
2046
|
return;
|
|
2047
2047
|
}
|
|
2048
2048
|
// New identity — user exists but has no tenant membership
|
|
2049
|
-
if (result.isNewIdentity && result.
|
|
2049
|
+
if (result.isNewIdentity && result.user) {
|
|
2050
2050
|
this.needsOnboarding.emit({
|
|
2051
2051
|
auth_method: result.authMethod || 'oauth',
|
|
2052
2052
|
oauth_provider: result.oauthProvider,
|
|
2053
2053
|
is_new_identity: true,
|
|
2054
|
-
identity:
|
|
2054
|
+
identity: {
|
|
2055
|
+
email: result.user.email,
|
|
2056
|
+
display_name: result.user.display_name,
|
|
2057
|
+
picture: result.user.photo_url,
|
|
2058
|
+
},
|
|
2055
2059
|
});
|
|
2056
2060
|
return;
|
|
2057
2061
|
}
|
|
@@ -2110,7 +2114,14 @@ class TenantLoginComponent {
|
|
|
2110
2114
|
}
|
|
2111
2115
|
// Auto-select if user has only one tenant
|
|
2112
2116
|
if (this.memberships.length === 1 && this.autoSelectSingleTenant) {
|
|
2113
|
-
|
|
2117
|
+
const m = this.memberships[0];
|
|
2118
|
+
// If login already returned a tenant-scoped token (via membership in response),
|
|
2119
|
+
// just emit — no need to call select-tenant again.
|
|
2120
|
+
if (loginResult?.membership) {
|
|
2121
|
+
this.tenantSelected.emit({ tenantId: m.tenant_id, tenantSlug: m.slug, role: m.role });
|
|
2122
|
+
return;
|
|
2123
|
+
}
|
|
2124
|
+
await this.selectAndContinue(m);
|
|
2114
2125
|
}
|
|
2115
2126
|
else {
|
|
2116
2127
|
// Show tenant selector
|