Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
060233e3
Commit
060233e3
authored
6 years ago
by
Tom Robinson
Committed by
Cam Saul
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
FE tweaks for session changes, no longer require setting cookie in JS
parent
873d310c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/auth/auth.js
+11
-21
11 additions, 21 deletions
frontend/src/metabase/auth/auth.js
frontend/src/metabase/setup/actions.js
+1
-5
1 addition, 5 deletions
frontend/src/metabase/setup/actions.js
with
12 additions
and
26 deletions
frontend/src/metabase/auth/auth.js
+
11
−
21
View file @
060233e3
...
...
@@ -6,7 +6,6 @@ import {
import
{
push
}
from
"
react-router-redux
"
;
import
MetabaseCookies
from
"
metabase/lib/cookies
"
;
import
MetabaseUtils
from
"
metabase/lib/utils
"
;
import
MetabaseAnalytics
from
"
metabase/lib/analytics
"
;
import
MetabaseSettings
from
"
metabase/lib/settings
"
;
...
...
@@ -36,10 +35,8 @@ export const login = createThunkAction(LOGIN, function(
}
try
{
let
newSession
=
await
SessionApi
.
create
(
credentials
);
// since we succeeded, lets set the session cookie
MetabaseCookies
.
setSessionCookie
(
newSession
.
id
);
// NOTE: this request will return a Set-Cookie header for the session
await
SessionApi
.
create
(
credentials
);
MetabaseAnalytics
.
trackEvent
(
"
Auth
"
,
"
Login
"
);
// TODO: redirect after login (carry user to intended destination)
...
...
@@ -59,13 +56,11 @@ export const loginGoogle = createThunkAction(LOGIN_GOOGLE, function(
)
{
return
async
function
(
dispatch
,
getState
)
{
try
{
let
newSession
=
await
SessionApi
.
createWithGoogleAuth
({
// NOTE: this request will return a Set-Cookie header for the session
await
SessionApi
.
createWithGoogleAuth
({
token
:
googleUser
.
getAuthResponse
().
id_token
,
});
// since we succeeded, lets set the session cookie
MetabaseCookies
.
setSessionCookie
(
newSession
.
id
);
MetabaseAnalytics
.
trackEvent
(
"
Auth
"
,
"
Google Auth Login
"
);
// TODO: redirect after login (carry user to intended destination)
...
...
@@ -87,13 +82,12 @@ export const loginGoogle = createThunkAction(LOGIN_GOOGLE, function(
export
const
LOGOUT
=
"
metabase/auth/LOGOUT
"
;
export
const
logout
=
createThunkAction
(
LOGOUT
,
function
()
{
return
function
(
dispatch
,
getState
)
{
// TODO: as part of a logout we want to clear out any saved state that we have about anything
// actively delete the session and remove the cookie
SessionApi
.
delete
();
// clear Google auth credentials if any are present
clearGoogleAuthCredentials
();
let
sessionId
=
MetabaseCookies
.
setSessionCookie
();
if
(
sessionId
)
{
// actively delete the session
SessionApi
.
delete
({
session_id
:
sessionId
});
}
MetabaseAnalytics
.
trackEvent
(
"
Auth
"
,
"
Logout
"
);
dispatch
(
push
(
"
/auth/login
"
));
...
...
@@ -118,16 +112,12 @@ export const passwordReset = createThunkAction(PASSWORD_RESET, function(
}
try
{
let
result
=
await
SessionApi
.
reset_password
({
// NOTE: this request will return a Set-Cookie header for the session
await
SessionApi
.
reset_password
({
token
:
token
,
password
:
credentials
.
password
,
});
if
(
result
.
session_id
)
{
// we should have a valid session that we can use immediately!
MetabaseCookies
.
setSessionCookie
(
result
.
session_id
);
}
MetabaseAnalytics
.
trackEvent
(
"
Auth
"
,
"
Password Reset
"
);
return
{
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/setup/actions.js
+
1
−
5
View file @
060233e3
//import _ from "underscore";
import
{
createAction
}
from
"
redux-actions
"
;
import
{
createThunkAction
}
from
"
metabase/lib/redux
"
;
import
MetabaseAnalytics
from
"
metabase/lib/analytics
"
;
import
MetabaseCookies
from
"
metabase/lib/cookies
"
;
import
MetabaseSettings
from
"
metabase/lib/settings
"
;
import
{
SetupApi
,
UtilApi
}
from
"
metabase/services
"
;
...
...
@@ -50,6 +48,7 @@ export const submitSetup = createThunkAction(SUBMIT_SETUP, function() {
let
{
setup
:
{
allowTracking
,
databaseDetails
,
userDetails
}
}
=
getState
();
try
{
// NOTE: this request will return a Set-Cookie header for the session
let
response
=
await
SetupApi
.
create
({
token
:
MetabaseSettings
.
get
(
"
setup_token
"
),
prefs
:
{
...
...
@@ -75,9 +74,6 @@ export const submitSetup = createThunkAction(SUBMIT_SETUP, function() {
export
const
completeSetup
=
createAction
(
COMPLETE_SETUP
,
function
(
apiResponse
,
)
{
// setup user session
MetabaseCookies
.
setSessionCookie
(
apiResponse
.
id
);
// clear setup token from settings
MetabaseSettings
.
setAll
({
setup_token
:
null
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment