LIHKG IT討論區(93) 跳糟跳著份伏工,伏到訓覺都叫春
咁辛苦為乜呀 2020-8-27 14:23:22 唔係send request 俾server side做handle?

Ads

嘴遁師青花 2020-8-27 14:30:45 ok, 咁我backend handle左 http://mydomain.com/?token=xxxxx

咁之後我redirect番user去http://mydomain.com(frontend)?frontend/user點知自己登入左

:^(
:^(
第三日學web
咁辛苦為乜呀 2020-8-27 14:38:22
:^(
嘴遁師青花 2020-8-27 15:06:48 sor可能我自己都唔知自己做緊咩
我reference緊
https://printmyroute.xyz/

我一禁connect with strava,就離開左原來個網,去左strava既auth

而我一authorize左,就被redirect左去
https://printmyroute.xyz/activity/?state=&code=xxxxxxxxxxx&scope=read,activity:read_all,profile:read_all,read_all


我拎住條code=xxxxxxxxxxx,就可以拎晒user係strava上面既資料

但係我唔知應該點handle https://printmyroute.xyz/activity/?state........
呢條url,令到個frontend知道登入左

之後我一直9 search
:^(
諗會唔會係用react router食條url呢......?
Mike_Chan 2020-8-27 15:07:14
:^(
eelonmuskk 2020-8-27 15:10:06
:^(
token會擺落local-storage
睇下人地點用jwt先啦你似乎真係基本都未識
嘴遁師青花 2020-8-27 15:10:18
:^(
Mike_Chan 2020-8-27 15:13:34
:^(
Mike_Chan 2020-8-27 15:39:01 想問下
如果我有個api想做到localhost get佢既時候會顯示多d野
其他人有無可能用fake ip扮localhost偷睇我d野?
名刀三代鬼徹 2020-8-27 15:39:32 你應該係講緊auth完之後既動作?
簡單set 一個 var, e.g. is_authed = true; 之後再用簡單
conditional rendering
return (
{ (is_authed) }  ? <YouComponent> : <div> you have not logged in yet</div>
)

類似係咁
想有系統D就 整兩套routes 一個係public 一個係private
private要 user auth左先可以入/睇到, public 就唔洗

token 係用front end send 野去backend先要用 or同其他app做communication先要用, 你拎完條TOKEN之後store in localstorage, CALL API果陣一再PASS條TOKEN過去
嘴遁師青花 2020-8-27 15:40:49 師兄屌得好,我搵到啦
https://www.graphql.college/implementing-github-oauth-flow/


window.location.href.match(/?code=(.*)/)

佢用呢句食番個code
:^(

Ads

嘴遁師青花 2020-8-27 15:49:55 你拎完條TOKEN之後store in localstorage:

岩岩搵到
window.location.href.match(/?code=(.*)/)
save低個auth code,再exchange token,
之後再save落local storage?
麥克馬斯特 2020-8-27 15:51:53
:^(
Mike_Chan 2020-8-27 16:01:27
:^(
手一黏便緊(UTC+9 2020-8-27 16:06:31 X-Http-Forwarded-For: 127.0.0.1
手一黏便緊(UTC+9 2020-8-27 16:07:47 試下吹relational algebra
RayGunn 2020-8-27 16:09:30
:^(
嘴遁師青花 2020-8-27 16:11:14
:^(
手一黏便緊(UTC+9 2020-8-27 16:12:11
:^(
eelonmuskk 2020-8-27 16:12:19 你係整緊social login?

Ads

嘴遁師青花 2020-8-27 16:15:57 整緊個web app 扲strava跑步data搞D野
初初諗住自己用
:^(
Mike_Chan 2020-8-27 16:16:49 咁都係set password算
:^(
手一黏便緊(UTC+9 2020-8-27 16:24:05 Why not both
Localhost && (cookie has correct password || manual input correct password)
燃堆卡 2020-8-27 16:24:50 巴打有detail嗎?
上過去, office好細, 聽聞D野一腳踢