Skip to content

Commit

Permalink
Merge branch 'development' into dev-to-sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
cbhernan committed Sep 16, 2024
2 parents 541f046 + c0c1a98 commit 3eb168b
Show file tree
Hide file tree
Showing 10 changed files with 403 additions and 370 deletions.
71 changes: 36 additions & 35 deletions functions/auth0/api/auth0.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const updateUser = onRequest(async (req, res) => {

if (user.lastName) {
updatedUserObject['family_name'] = user.lastName;
updatedUserObject['name'] += ` ${user.lastName}`;
}

const primaryAddress = {};
Expand Down Expand Up @@ -354,6 +355,40 @@ export const unenrollMFA = onRequest(async (req, res) => {
}
});

export const removeConnection = onRequest(async (req, res) => {
try {
const {
connectionId
} = req.body;

if (!connectionId) {
res.status(400).send('Invalid request - missing required fields.');
return;
}

const config = {
method: 'delete',
maxBodyLength: Infinity,
url: `https://${auth0Domain}/api/v2/grants/${connectionId}`,
headers: {
'Authorization': `Bearer ${await getAccessToken()}`
}
};

await axios.request(config)
res.status(200).send();
} catch (error) {
console.log(error);

const {
status = 500,
message = '',
} = error.response;

return res.status(status).send(message);
};
});

const getConnectedServices = async (userId) => {

if (!userId) {
Expand Down Expand Up @@ -427,38 +462,4 @@ const getConnectedServices = async (userId) => {

return res.status(status).send(message);
}
};

export const removeConnection = onRequest(async (req, res) => {
try {
const {
connectionId
} = req.body;

if (!connectionId) {
res.status(400).send('Invalid request - missing required fields.');
return;
}

const config = {
method: 'delete',
maxBodyLength: Infinity,
url: `https://${auth0Domain}/api/v2/grants/${connectionId}`,
headers: {
'Authorization': `Bearer ${await getAccessToken()}`
}
};

await axios.request(config)
res.status(200).send();
} catch (error) {
console.log(error);

const {
status = 500,
message = '',
} = error.response;

return res.status(status).send(message);
};
});
};
102 changes: 58 additions & 44 deletions functions/auth0/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 functions/auth0/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@google-cloud/functions-framework": "^3.3.0",
"axios": "^1.7.4",
"express": "^4.18.2",
"express": "^4.21.0",
"firebase-admin": "^12.0.0",
"firebase-functions": "^5.0.1",
"jsonwebtoken": "9.0.2"
Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/user_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class UserProvider extends ChangeNotifier {

Future<void> logout() => auth0Web.logout(
federated: false,
returnToUrl: 'https://angeleno.lacity.org/'
returnToUrl: 'https://sandbox.account.lacity.gov/'
);

User? get user => _user;
Expand Down
Loading

0 comments on commit 3eb168b

Please sign in to comment.