fix: logout link is broken (#5698)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
This commit is contained in:
Alexander Matyushentsev 2021-03-06 20:07:33 -08:00 committed by GitHub
parent c0985fb0c9
commit e3163e317a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -63,7 +63,14 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
logoutRedirectURL := strings.TrimRight(strings.TrimLeft(argoCDSettings.URL, "/"), "/") + strings.TrimRight(strings.TrimLeft(h.rootPath, "/"), "/")
argoURL := argoCDSettings.URL
if argoURL == "" {
// golang does not provide any easy way to determine scheme of current request
// so redirecting ot http which will auto-redirect too https if necessary
argoURL = fmt.Sprintf("http://%s", r.Host)
}
logoutRedirectURL := strings.TrimRight(strings.TrimLeft(argoURL, "/"), "/") + strings.TrimRight(strings.TrimLeft(h.rootPath, "/"), "/")
cookies := r.Cookies()
tokenString, err = httputil.JoinCookies(common.AuthCookieName, cookies)

View file

@ -1,8 +1,11 @@
import {DataLoader, Page as ArgoPage, Toolbar, Utils} from 'argo-ui';
import * as React from 'react';
import {BehaviorSubject, Observable} from 'rxjs';
import {Context, ContextApis} from '../../context';
import {services} from '../../services';
import requests from '../../services/requests';
const mostRecentLoggedIn = new BehaviorSubject<boolean>(false);
import './page.scss';
@ -20,7 +23,7 @@ export const AddAuthToToolbar = (init: Toolbar | Observable<Toolbar>, ctx: Conte
<DataLoader key='loginPanel' load={() => isLoggedIn()}>
{loggedIn =>
loggedIn ? (
<a key='logout' onClick={() => ctx.navigation.goto('/auth/logout')}>
<a key='logout' onClick={() => (window.location.href = requests.toAbsURL('/auth/logout'))}>
Log out
</a>
) : (