feat: Add availableTeams to auth.info endpoint (#3981)
* Index emails migration * feat: Add available teams to auth.info endpoint * test * separate presenter * Include data from sessions cookie, include likely logged in state * test * test: Add test for team only in session cookie * Suggested query change in PR feedback
This commit is contained in:
@@ -405,6 +405,23 @@ class User extends ParanoidModel {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a list of teams that have a user matching this user's email.
|
||||
*
|
||||
* @returns A promise resolving to a list of teams
|
||||
*/
|
||||
availableTeams = async () => {
|
||||
return Team.findAll({
|
||||
include: [
|
||||
{
|
||||
model: this.constructor as typeof User,
|
||||
required: true,
|
||||
where: { email: this.email },
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
demote = async (to: UserRole, options?: SaveOptions<User>) => {
|
||||
const res = await (this.constructor as typeof User).findAndCountAll({
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user