doei
07/17/2022, 3:46 PMmamousavi
07/17/2022, 3:55 PMNaf
07/17/2022, 4:05 PMsupertokens-web
when the user's payload changes? Right now I'm getting around it by refreshing the session and doing what I need to do in that event handler, but it would be nice to have its own event actionNoobster123
07/17/2022, 6:13 PMsharma
07/18/2022, 1:18 AMsupertokensEmailPassword.resetPassword
emailpassword.js:1 Uncaught (in promise) Error: SuperTokensWindowHandler must be initialized before calling this method.
at e.getReferenceOrThrow (emailpassword.js:1:105686)
at t.getQueryParams (emailpassword.js:1:35831)
at Object.getResetPasswordTokenFromURL (emailpassword.js:1:22726)
at e.getResetPasswordTokenFromURL (emailpassword.js:1:14504)
at resetPassword (reset-password?token=NjJjZTUxOTA2MWI2NmE5NmQ2NzYyNjlmOWQyOWE1OTVhZGJiNTYxNWU5NDk3YzU2ZDJlYjNhNTJkYmRkMzU4ZjYwMzM4YmJlOGZkODcyNTRhN2Y0ODQ1YmNkNDZjMmEw&rid=emailpassword:25:70)
rp
07/18/2022, 4:16 AMwdjzr
07/18/2022, 12:36 PMwdjzr
07/18/2022, 12:37 PMmajortom
07/18/2022, 1:01 PMNoobster123
07/18/2022, 2:32 PMaV
07/18/2022, 5:25 PMrp
07/18/2022, 5:37 PMaV
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'
}