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/'),
|
||||
);
|
||||
|
||||
// final me = jsonDecode(jsonMe);
|
||||
final me = jsonDecode(jsonMe);
|
||||
|
||||
// final user = me['user'];
|
||||
// final transformed = {
|
||||
// "username": user['username'],
|
||||
// "name": user['name'],
|
||||
// "email": user['email'],
|
||||
// "attributes.settings.locale": user['settings']['locale'],
|
||||
// "attributes.sshPublicKeys":
|
||||
// "foooooooobar!", // fix oder aus anderer Quelle
|
||||
// "component": "ak-stage-prompt",
|
||||
// };
|
||||
final user = me['user'];
|
||||
final transformed = {
|
||||
"username": user['username'],
|
||||
"name": user['name'],
|
||||
"email": user['email'],
|
||||
"attributes.settings.locale": user['settings']['locale'],
|
||||
"attributes.sshPublicKeys":
|
||||
"foooooooobar :O :O!", // fix oder aus anderer Quelle
|
||||
"component": "ak-stage-prompt",
|
||||
};
|
||||
|
||||
// final push = jsonEncode(transformed);
|
||||
print(user);
|
||||
print(transformed);
|
||||
|
||||
final push =
|
||||
'{"username":"lemoer","name":"Leonardo Mörlein","email":"me@irrelefant.net","attributes.settings.locale":"","attributes.sshPublicKeys":"BLA!","component":"ak-stage-prompt"}';
|
||||
|
||||
print(push);
|
||||
final push = jsonEncode(transformed);
|
||||
|
||||
final response0 = await client.get(
|
||||
Uri.parse(
|
||||
@ -215,29 +213,16 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
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) {
|
||||
throw Exception(
|
||||
"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'];
|
||||
if (newLocation != null) {
|
||||
print("Redirecting to: $newLocation");
|
||||
await launchUrl(Uri.parse(newLocation));
|
||||
} else {
|
||||
if (newLocation == null) {
|
||||
throw Exception("No redirect location found in response headers.");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user