Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
eadfcfda
Commit
eadfcfda
authored
Mar 12, 2021
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Mar 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `authDomain` to `session` store
parent
caec1d11
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
6 deletions
+36
-6
session.js
src/sidebar/store/modules/session.js
+18
-1
groups-test.js
src/sidebar/store/modules/test/groups-test.js
+3
-1
session-test.js
src/sidebar/store/modules/test/session-test.js
+15
-4
No files found.
src/sidebar/store/modules/session.js
View file @
eadfcfda
...
...
@@ -23,8 +23,16 @@ const initialProfile = {
userid
:
null
,
};
function
init
()
{
function
init
(
settings
)
{
return
{
/**
* The app's authentication domain, from settings
* FIXME: This returns an empty string when `authDomain` is missing
* because other app logic has long assumed its string-y presence:
* behavior when it's missing is undefined. This setting should be
* enforced similarly to how `apiUrl` is enforced.
*/
authDomain
:
settings
?.
authDomain
??
''
,
/**
* Profile object fetched from the `/api/profile` endpoint.
*/
...
...
@@ -52,6 +60,14 @@ function updateProfile(profile) {
};
}
/**
*
* @returns {string}
*/
function
authDomain
(
state
)
{
return
state
.
authDomain
;
}
/**
* Return true if a user is logged in and false otherwise.
*
...
...
@@ -103,6 +119,7 @@ export default storeModule({
},
selectors
:
{
authDomain
,
hasFetchedProfile
,
isFeatureEnabled
,
isLoggedIn
,
...
...
src/sidebar/store/modules/test/groups-test.js
View file @
eadfcfda
...
...
@@ -71,7 +71,9 @@ describe('sidebar/store/modules/groups', () => {
let
store
;
beforeEach
(()
=>
{
store
=
createStore
([
groups
,
session
]);
// The empty second argument (settings) needed here because of the
// dependency on the `session` module
store
=
createStore
([
groups
,
session
],
[{}]);
});
describe
(
'focusGroup'
,
()
=>
{
...
...
src/sidebar/store/modules/test/session-test.js
View file @
eadfcfda
import
createStore
from
'../../create-store'
;
import
session
from
'../session'
;
describe
(
'sidebar/store/modules/session'
,
function
()
{
describe
(
'sidebar/store/modules/session'
,
()
=>
{
let
fakeSettings
;
let
store
;
beforeEach
(()
=>
{
store
=
createStore
([
session
]);
fakeSettings
=
{};
store
=
createStore
([
session
],
[
fakeSettings
]);
});
describe
(
'#updateProfile'
,
function
()
{
it
(
'updates the profile data'
,
function
()
{
describe
(
'#updateProfile'
,
()
=>
{
it
(
'updates the profile data'
,
()
=>
{
const
newProfile
=
Object
.
assign
({
userid
:
'john'
});
store
.
updateProfile
({
userid
:
'john'
});
assert
.
deepEqual
(
store
.
profile
(),
newProfile
);
});
});
describe
(
'#authDomain'
,
()
=>
{
it
(
'returns the authDomain from the settings'
,
()
=>
{
fakeSettings
.
authDomain
=
'foo.com'
;
store
=
createStore
([
session
],
[
fakeSettings
]);
assert
.
equal
(
store
.
authDomain
(),
'foo.com'
);
});
});
describe
(
'#isLoggedIn'
,
()
=>
{
[
{
userid
:
'john'
,
expectedIsLoggedIn
:
true
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment