main: update authentik oauth push action
This commit is contained in:
parent
6357c4e2ae
commit
c4fe7a1afa
@ -157,25 +157,23 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Uri.parse('https://auth.leinelab.org/api/v3/core/users/me/'),
|
Uri.parse('https://auth.leinelab.org/api/v3/core/users/me/'),
|
||||||
);
|
);
|
||||||
|
|
||||||
// final me = jsonDecode(jsonMe);
|
final me = jsonDecode(jsonMe);
|
||||||
|
|
||||||
// final user = me['user'];
|
final user = me['user'];
|
||||||
// final transformed = {
|
final transformed = {
|
||||||
// "username": user['username'],
|
"username": user['username'],
|
||||||
// "name": user['name'],
|
"name": user['name'],
|
||||||
// "email": user['email'],
|
"email": user['email'],
|
||||||
// "attributes.settings.locale": user['settings']['locale'],
|
"attributes.settings.locale": user['settings']['locale'],
|
||||||
// "attributes.sshPublicKeys":
|
"attributes.sshPublicKeys":
|
||||||
// "foooooooobar!", // fix oder aus anderer Quelle
|
"foooooooobar :O :O!", // fix oder aus anderer Quelle
|
||||||
// "component": "ak-stage-prompt",
|
"component": "ak-stage-prompt",
|
||||||
// };
|
};
|
||||||
|
|
||||||
// final push = jsonEncode(transformed);
|
print(user);
|
||||||
|
print(transformed);
|
||||||
|
|
||||||
final push =
|
final push = jsonEncode(transformed);
|
||||||
'{"username":"lemoer","name":"Leonardo Mörlein","email":"me@irrelefant.net","attributes.settings.locale":"","attributes.sshPublicKeys":"BLA!","component":"ak-stage-prompt"}';
|
|
||||||
|
|
||||||
print(push);
|
|
||||||
|
|
||||||
final response0 = await client.get(
|
final response0 = await client.get(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
@ -215,29 +213,16 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
headers: {'Content-Type': 'application/json', 'Cookie': sessionCookie},
|
headers: {'Content-Type': 'application/json', 'Cookie': sessionCookie},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Authentik expects a redirect after the POST request and only writes
|
||||||
|
// the data to the database after fetching the redirect location.
|
||||||
if (response.statusCode != 302) {
|
if (response.statusCode != 302) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Expected a redirect (302) response, but got ${response.statusCode}",
|
"Expected a redirect (302) response, but got ${response.statusCode}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (response.statusCode == 200) {
|
|
||||||
// print("User data updated successfully.");
|
|
||||||
// print("Response body:");
|
|
||||||
// print(response.body);
|
|
||||||
// response.headers.toString().split('\n').forEach(print);
|
|
||||||
// } else {
|
|
||||||
// print("Error updating user data: ${response.statusCode}");
|
|
||||||
// print("Response body:");
|
|
||||||
// print(response.body);
|
|
||||||
// print(response.headers.toString());
|
|
||||||
// }
|
|
||||||
|
|
||||||
final newLocation = response.headers['location'];
|
final newLocation = response.headers['location'];
|
||||||
if (newLocation != null) {
|
if (newLocation == null) {
|
||||||
print("Redirecting to: $newLocation");
|
|
||||||
await launchUrl(Uri.parse(newLocation));
|
|
||||||
} else {
|
|
||||||
throw Exception("No redirect location found in response headers.");
|
throw Exception("No redirect location found in response headers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user