| ... | ... | @@ -6,7 +6,6 @@ const http = @import("apple_pie"); |
| 6 | 6 | const files = @import("self/files"); |
| 7 | 7 | const pek = @import("pek"); |
| 8 | 8 | const zfetch = @import("zfetch"); |
| 9 | | const json = @import("json"); |
| 10 | 9 | const extras = @import("extras"); |
| 11 | 10 | const UrlValues = @import("UrlValues"); |
| 12 | 11 | const Base = @This(); |
| ... | ... | @@ -280,24 +279,24 @@ pub fn Handlers(comptime T: type) type { |
| 280 | 279 | try req.do(.POST, headers, try params.encode()); |
| 281 | 280 | const r = req.reader(); |
| 282 | 281 | const body_content = try r.readAllAlloc(alloc, 1024 * 1024 * 5); |
| 283 | | const val = try json.parse(alloc, body_content); |
| 282 | const val = try extras.parse_json(alloc, body_content); |
| 284 | 283 | |
| 285 | | const at = val.get("access_token") orelse return try fail(response, "Identity Provider Login Error!\n{s}", .{body_content}); |
| 284 | const at = val.root.object.get("access_token") orelse return try fail(response, body_writer, "Identity Provider Login Error!\n{s}", .{body_content}); |
| 286 | 285 | |
| 287 | 286 | const req2 = try zfetch.Request.init(alloc, client.provider.me_url, null); |
| 288 | 287 | var headers2 = zfetch.Headers.init(alloc); |
| 289 | | try headers2.appendValue("Authorization", try std.fmt.allocPrint(alloc, "Bearer {s}", .{at.String})); |
| 288 | try headers2.appendValue("Authorization", try std.fmt.allocPrint(alloc, "Bearer {s}", .{at.string})); |
| 290 | 289 | try headers2.appendValue("Accept", "application/json"); |
| 291 | 290 | |
| 292 | 291 | // TODO print error message if this fails |
| 293 | 292 | try req2.do(.GET, headers2, null); |
| 294 | 293 | const r2 = req2.reader(); |
| 295 | 294 | const body_content2 = try r2.readAllAlloc(alloc, 1024 * 1024 * 5); |
| 296 | | const val2 = try json.parse(alloc, body_content2); |
| 295 | const val2 = try extras.parse_json(alloc, body_content2); |
| 297 | 296 | |
| 298 | | const id = try fixId(alloc, val2.get(client.provider.id_prop).?); |
| 299 | | const name = val2.get(client.provider.name_prop).?.String; |
| 300 | | try T.saveInfo(response, request, client.provider, id, name, val, val2); |
| 297 | const id = try fixId(alloc, val2.root.object.get(client.provider.id_prop).?); |
| 298 | const name = val2.root.object.get(client.provider.name_prop).?.string; |
| 299 | try T.saveInfo(response, alloc, client.provider, id, name, val.root, val2.root); |
| 301 | 300 | |
| 302 | 301 | try response.headers.put("Location", T.doneUrl); |
| 303 | 302 | try response.writeHeader(.found); |