Skip to content

Commit

Permalink
fix up laravel compatibility & routing
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpr03 committed Jan 10, 2022
1 parent 05dc4b4 commit c1a9d71
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
20 changes: 15 additions & 5 deletions hardwhere.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
diff --git a/app/Http/Controllers/HardWhereController.php b/app/Http/Controllers/HardWhereController.php
new file mode 100644
index 000000000..7a67d5a6d
index 000000000..9d3d8ea9e
--- /dev/null
+++ b/app/Http/Controllers/HardWhereController.php
@@ -0,0 +1,83 @@
@@ -0,0 +1,93 @@
+<?php
+
+namespace App\Http\Controllers;
Expand Down Expand Up @@ -80,11 +80,21 @@ index 000000000..7a67d5a6d
+ });
+ $token = $user->createToken('HardWhere-WebView')->accessToken;
+ $login_token = Str::random(40);
+ $response = Http::post('http://localhost:8000/HardWhere/internal/autologin', [
+// $response = Http::post('http://localhost:8000/HardWhere/internal/autologin', [
+// 'api_token' => $token,
+// 'login_token' => $login_token,
+// ]);
+ $ch = curl_init('http://localhost:8000/HardWhere/internal/autologin');
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
+ 'api_token' => $token,
+ 'login_token' => $login_token,
+ ]);
+ return redirect('/HardWhere/autologin/'+$login_token);
+ ]));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
+ $result = curl_exec($ch);
+ curl_close($ch);
+ return redirect('/HardWhere/autologin/' . $login_token);
+ }
+}
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php
Expand Down
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ async fn main() -> Result<()> {
.data(auto_login_tokens.clone())
.data(ClientBuilder::new().header(ACCEPT,"application/json").header(CONTENT_TYPE,"application/json").finish())
// developer for local testing
.service(web::scope("/HardWhere")

// .service(web::scope("/HardWhere")

.service(web::resource("/api/checkedout").route(web::get().to(api::lent_list)))
.service(web::resource("/api/checkout").route(web::post().to(api::lent_asset)))
Expand All @@ -107,8 +108,8 @@ async fn main() -> Result<()> {
.service(web::resource("/logout").route(web::get().to(webview::logout)))
.service(web::resource("/autologin/{auth_token}").route(web::get().to(webview::auto_login)))
.service(Files::new("/static", "static/").show_files_listing())
// developer for local testing
)

// )
})
.bind(&bind)?
.run()
Expand Down

0 comments on commit c1a9d71

Please sign in to comment.