Monorepo for Tangled

appview/oauth: remove `AuthReturnInfo`

Signed-off-by: Seongmin Lee <git@boltless.me>

boltless.me 1614459d 7eddbe6f

verified
+6 -14
+3 -9
appview/oauth/accounts.go
··· 126 } 127 } 128 129 - type AuthReturnInfo struct { 130 - ReturnURL string 131 - } 132 - 133 func (o *OAuth) SetAuthReturn(w http.ResponseWriter, r *http.Request, returnURL string) error { 134 session, err := o.SessStore.Get(r, AuthReturnName) 135 if err != nil { ··· 145 return session.Save(r, w) 146 } 147 148 - func (o *OAuth) GetAuthReturn(r *http.Request) *AuthReturnInfo { 149 session, err := o.SessStore.Get(r, AuthReturnName) 150 if err != nil || session.IsNew { 151 - return &AuthReturnInfo{} 152 } 153 154 returnURL, _ := session.Values[AuthReturnURL].(string) 155 156 - return &AuthReturnInfo{ 157 - ReturnURL: returnURL, 158 - } 159 } 160 161 func (o *OAuth) ClearAuthReturn(w http.ResponseWriter, r *http.Request) error {
··· 126 } 127 } 128 129 func (o *OAuth) SetAuthReturn(w http.ResponseWriter, r *http.Request, returnURL string) error { 130 session, err := o.SessStore.Get(r, AuthReturnName) 131 if err != nil { ··· 141 return session.Save(r, w) 142 } 143 144 + func (o *OAuth) GetAuthReturn(r *http.Request) string { 145 session, err := o.SessStore.Get(r, AuthReturnName) 146 if err != nil || session.IsNew { 147 + return "" 148 } 149 150 returnURL, _ := session.Values[AuthReturnURL].(string) 151 152 + return returnURL 153 } 154 155 func (o *OAuth) ClearAuthReturn(w http.ResponseWriter, r *http.Request) error {
+3 -5
appview/oauth/handler.go
··· 100 } 101 } 102 103 - redirectURL := "/" 104 - if authReturn.ReturnURL != "" { 105 - redirectURL = authReturn.ReturnURL 106 } 107 - 108 - http.Redirect(w, r, redirectURL, http.StatusFound) 109 } 110 111 func (o *OAuth) addToDefaultSpindle(did string) {
··· 100 } 101 } 102 103 + if authReturn == "" { 104 + authReturn = "/" 105 } 106 + http.Redirect(w, r, authReturn, http.StatusFound) 107 } 108 109 func (o *OAuth) addToDefaultSpindle(did string) {