Skip to content
Snippets Groups Projects

fix: avoid to send to backend null access or refresh token

3 files
+ 27
8
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -26,6 +26,7 @@ import {
import {DefaultSolidifyEnvironment} from "../environments/environment.solidify-defaults";
import {ENVIRONMENT} from "../injection-tokens";
import {AbstractBaseService} from "../services/abstract-base.service";
import {isNullOrUndefinedOrWhiteString} from "../tools";
import {
OAuthErrorEvent,
OAuthEvent,
@@ -92,9 +93,14 @@ export class OAuth2Service extends AbstractBaseService {
* there is no refresh_token in this flow.
*/
public refreshToken(): Observable<boolean> {
const refreshToken = this._storage.getItem("refresh_token");
if (isNullOrUndefinedOrWhiteString(refreshToken)) {
this.eventsSubject.next(new OAuthErrorEvent("token_refresh_error", new Error("Refresh token is not defined")));
return of(false);
}
let params = new HttpParams()
.set("grant_type", "refresh_token")
.set("refresh_token", this._storage.getItem("refresh_token"))
.set("refresh_token", refreshToken)
.set("scope", this.environment.scope);
if (this.environment.dummyClientSecret) {
params = params.set("client_secret", this.environment.dummyClientSecret);
Loading