Skip to content

Commit 2499511

Browse files
committed
Logout endpoint
Delete in memory session when user logout from mcs lint fixes Click logout button triggers logout request Clicking the actual logout button send the POST /logout request on mcs UI
1 parent b1df170 commit 2499511

File tree

14 files changed

+540
-7
lines changed

14 files changed

+540
-7
lines changed

cmd/mcs/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/minio/cli"
3232
)
3333

34-
// Help template for m3.
34+
// Help template for mcs.
3535
var mcsHelpTemplate = `NAME:
3636
{{.Name}} - {{.Usage}}
3737
@@ -57,10 +57,10 @@ var appCmds = []cli.Command{
5757
}
5858

5959
func newApp(name string) *cli.App {
60-
// Collection of m3 commands currently supported are.
60+
// Collection of mcs commands currently supported are.
6161
var commands []cli.Command
6262

63-
// Collection of m3 commands currently supported in a trie tree.
63+
// Collection of mcs commands currently supported in a trie tree.
6464
commandsTree := trie.NewTrie()
6565

6666
// registerCommand registers a cli command.

portal-ui/src/common/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class API {
3030
storage.removeItem("token");
3131
window.location.href = "/";
3232
}
33-
this.onError(err);
33+
return this.onError(err);
3434
});
3535
}
3636

portal-ui/src/screens/Console/Menu.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
} from "../../icons";
3737
import { createStyles, Theme } from "@material-ui/core/styles";
3838
import PersonIcon from "@material-ui/icons/Person";
39+
import api from "../../common/api";
3940

4041
const styles = (theme: Theme) =>
4142
createStyles({
@@ -91,9 +92,20 @@ interface MenuProps {
9192

9293
class Menu extends React.Component<MenuProps> {
9394
logout() {
94-
storage.removeItem("token");
95-
this.props.userLoggedIn(false);
96-
history.push("/");
95+
const deleteSession = () => {
96+
storage.removeItem("token");
97+
this.props.userLoggedIn(false);
98+
history.push("/");
99+
}
100+
api
101+
.invoke("POST", `/api/v1/logout`)
102+
.then(() => {
103+
deleteSession();
104+
})
105+
.catch((err: any) => {
106+
console.log(err);
107+
deleteSession();
108+
});
97109
}
98110

99111
render() {

restapi/configure_mcs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ func configureAPI(api *operations.McsAPI) http.Handler {
7070

7171
// Register login handlers
7272
registerLoginHandlers(api)
73+
// Register logout handlers
74+
registerLogoutHandlers(api)
7375
// Register bucket handlers
7476
registerBucketsHandlers(api)
7577
// Register all users handlers

restapi/embedded_spec.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

restapi/operations/mcs_api.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

restapi/operations/user_api/logout.go

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

restapi/operations/user_api/logout_parameters.go

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)