Skip to content

Commit

Permalink
refactor: small consistency improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Oct 21, 2024
1 parent 4143257 commit 9c59148
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .circleci/forceRunCI.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ branch=`git rev-parse --abbrev-ref HEAD`

cdiCoreMap='{ "5.2": "feat/oauth/remaining-changes" }'
cdiPluginInterfaceMap='{ "5.2": "feat/oauth/remaining-changes" }'
fdiNodeMap='{ "3.1": "21.0", "4.0": "21.0" }'
fdiNodeMap='{ "3.1": "feat/add_clientId_secret_and_refreshTokenRotation_settings", "4.0": "feat/add_clientId_secret_and_refreshTokenRotation_settings" }'
fdiWebsiteMap='{ "1.17": "20.1", "1.18": "20.1", "1.19": "20.1", "2.0": "20.1", "3.0": "20.1", "3.1": "20.1", "4.0": "20.1" }'
fdiAuthReactMap='{ "3.1": "0.49", "4.0": "0.49" }'
fdiAuthReactMap='{ "3.1": "0.48", "4.0": "0.48" }'

data=`jq -cn --arg branch "$branch" \
--arg cdiCoreMap "$cdiCoreMap" \
Expand Down
11 changes: 9 additions & 2 deletions lib/build/recipe/oauth2provider/api/loginInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../../utils");
const error_1 = __importDefault(require("../../../error"));
async function loginInfoGET(apiImplementation, options, userContext) {
var _a;
var _a, _b;
if (apiImplementation.loginInfoGET === undefined) {
return false;
}
Expand All @@ -41,7 +41,14 @@ async function loginInfoGET(apiImplementation, options, userContext) {
loginChallenge,
userContext,
});
utils_1.send200Response(options.res, response);
if ("error" in response) {
utils_1.sendNon200Response(options.res, (_b = response.statusCode) !== null && _b !== void 0 ? _b : 400, {
error: response.error,
error_description: response.errorDescription,
});
} else {
utils_1.send200Response(options.res, response);
}
return true;
}
exports.default = loginInfoGET;
12 changes: 10 additions & 2 deletions lib/ts/recipe/oauth2provider/api/loginInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* under the License.
*/

import { send200Response } from "../../../utils";
import { send200Response, sendNon200Response } from "../../../utils";
import { APIInterface, APIOptions } from "..";
import { UserContext } from "../../../types";
import SuperTokensError from "../../../error";
Expand Down Expand Up @@ -43,6 +43,14 @@ export default async function loginInfoGET(
userContext,
});

send200Response(options.res, response);
if ("error" in response) {
sendNon200Response(options.res, response.statusCode ?? 400, {
error: response.error,
error_description: response.errorDescription,
});
} else {
send200Response(options.res, response);
}

return true;
}
3 changes: 1 addition & 2 deletions lib/ts/recipe/oauth2provider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ export type LoginRequest = {
export type TokenInfo = {
// The access token issued by the authorization server.
access_token?: string;
// The lifetime in seconds of the access token. For example, the value "3600" denotes that the access token will expire in one hour from the time the response was generated.
// integer <int64>
// The lifetime in seconds of the access token (integer). For example, the value "3600" denotes that the access token will expire in one hour from the time the response was generated.
expires_in: number;
// To retrieve a refresh token request the id_token scope.
id_token?: string;
Expand Down

0 comments on commit 9c59148

Please sign in to comment.