Skip to content

Commit

Permalink
Merge pull request #155 from Creatoon/loginBug
Browse files Browse the repository at this point in the history
fix: token expiration bug
  • Loading branch information
Creatoon authored Jun 23, 2023
2 parents 610a440 + 0f8f52e commit 679a399
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metacall/deploy",
"version": "0.1.28",
"version": "0.1.26",
"description": "Tool for deploying into MetaCall FaaS platform.",
"main": "dist/index.js",
"bin": {
Expand Down
11 changes: 10 additions & 1 deletion src/cli/validateToken.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { API as APIInterface } from '@metacall/protocol/protocol';
import { save } from '../config';
import { unlink } from 'fs/promises';
import { configFilePath, save } from '../config';
import { exists } from '../utils';
import args from './args';
import { error, info } from './messages';

const handleValidateToken = async (api: APIInterface): Promise<void> => {
const validToken = await api.validate();

if (!validToken) {
const token = await api.refresh();
await save({ token });
Expand All @@ -23,6 +26,12 @@ const validateToken = async (api: APIInterface): Promise<void> => {
return error('FaaS is not serving locally.');
}

// Removing cache such that user will have to login again.

const configFile = configFilePath();

(await exists(configFile)) && (await unlink(configFile));

info('Try to login again!');

return error(
Expand Down

0 comments on commit 679a399

Please sign in to comment.