aV
07/18/2022, 5:53 PMveritas
07/18/2022, 6:39 PMArashiTempesta
07/18/2022, 11:28 PMKillian
07/19/2022, 4:28 AMKillian
07/19/2022, 4:28 AMjavascript
const createRole = async () => {
const response = await UserRoles.createNewRoleOrAddPermissions("user", []);
console.log(response);
if (response.createdNewRole === false) {
console.log("Role already exists");
}
};
createRole();
Killian
07/19/2022, 4:29 AMrp
07/19/2022, 4:31 AMKillian
07/19/2022, 4:31 AMJota
07/19/2022, 11:45 AMservice: new STMPService({
^
TypeError: STMPService is not a constructor `
sharma
07/19/2022, 12:02 PMsharma
07/19/2022, 1:30 PMsupertokensEmailPassword.signUp
, is the returned promise rejected in case of FIELD_ERROR?
Initially I wrote the code inside .catch to deal with FIELD_ERROR but on debugging found that the code does not reach .catch
, but it is inside .then
.
Is it intended?Jota
07/19/2022, 2:02 PMrp
07/19/2022, 2:15 PMnikolaiavich
07/19/2022, 4:41 PMsession: Session
guard ?rp
07/19/2022, 4:52 PMAlankazam
07/19/2022, 5:03 PMKillian
07/19/2022, 11:28 PMjavascript
Session.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
createNewSession: async function (input) {
let userId = input.userId;
let roles = await UserRoles.getRolesForUser(userId);
input.accessTokenPayload = {
...input.accessTokenPayload,
roles,
};
return originalImplementation.createNewSession(input);
},
};
},
},
}),
Frontend:
javascript
import SuperTokens from "supertokens-react-native";
import useAppStore from "../zustand/auth-store";
async function checkForSession() {
if (await SuperTokens.doesSessionExist()) {
const userId = await SuperTokens.getUserId();
console.log("UserId: " + userId);
const roles = await SuperTokens.getAccessTokenPayloadSecurely();
console.log(roles);
useAppStore.setState({
isAuthenticated: true,
userId: userId,
});
} else {
useAppStore.setState({
isAuthenticated: false,
userId: null,
});
}
}
export default checkForSession;
Output:
javascript
UserId: 8cba27de-db0c-43ea-9d76-0ac6a44d7a38
UserId: 8cba27de-db0c-43ea-9d76-0ac6a44d7a38
Object {}
Object {}
Object in this case is the output of
javascript
console.log(roles);
Killian
07/19/2022, 11:40 PMjavascript
async function getUsersThatHaveRole(role: string) {
const response = await UserRoles.getUsersThatHaveRole(role);
console.log(response);
if (response.status === "UNKNOWN_ROLE_ERROR") {
// No such role exists
return;
}
const users: string[] = response.users;
}
javascript
{
users: [
'8cba27de-db0c-43ea-9d76-0ac6a44d7a38',
'1aac8fa3-5a95-4016-902f-1613d8e339cb'
],
status: 'OK'
}
Killian
07/19/2022, 11:49 PMshowtim3
07/20/2022, 7:17 AMAbhishek | TechVZero
07/20/2022, 8:11 AMAbhishek | TechVZero
07/20/2022, 8:11 AMrp
07/21/2022, 3:39 AMIaS1506
07/21/2022, 7:58 AMFinnTheHero
07/21/2022, 11:27 AMAlankazam
07/21/2022, 3:43 PM{
"error": "The middleware couldn't serve the API path /signin, method: post. If this is an unexpected behaviour, please create an issue here: https://github.com/supertokens/supertokens-node/issues"
}
Note¹: The /signup path works normally.
Note²: I'm using the following recipes in order: Session, UserMetadata, UserRoles, PasswordLess, EmailPassword
Can you tell me how I can diagnose this problem?rp
07/21/2022, 4:07 PMArjun
07/21/2022, 7:29 PMJake
07/23/2022, 2:08 AMrp
07/23/2022, 3:49 AMrp
07/23/2022, 3:49 AM