forked from Graylog2/graylog2-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Graylog2#8681 from Graylog2/improve-user-data-hand…
…ling Implement UsersActions and User class
- Loading branch information
Showing
21 changed files
with
711 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// @flow strict | ||
import Reflux from 'reflux'; | ||
|
||
import User from 'logic/users/User'; | ||
import { singletonActions } from 'views/logic/singleton'; | ||
import type { RefluxActions } from 'stores/StoreTypes'; | ||
|
||
export type Token = { | ||
token_name: string, | ||
token: string, | ||
last_access: string, | ||
}; | ||
|
||
export type ChangePasswordRequest = { | ||
old_password: string, | ||
password: string, | ||
}; | ||
|
||
type UsersActionsType = RefluxActions<{ | ||
create: (request: any) => Promise<string[]>, | ||
loadUsers: () => Promise<User[]>, | ||
load: (username: string) => Promise<User>, | ||
deleteUser: (username: string) => Promise<string[]>, | ||
changePassword: (username: string, request: ChangePasswordRequest) => Promise<void>, | ||
update: (username: string, request: any) => Promise<void>, | ||
createToken: (username: string, tokenName: string) => Promise<Token>, | ||
deleteToken: (username: string, tokenId: string, tokenName: string) => Promise<string[]>, | ||
loadTokens: (username: string) => Promise<Token[]>, | ||
}>; | ||
|
||
const UsersActions: UsersActionsType = singletonActions( | ||
'Users', | ||
() => Reflux.createActions({ | ||
create: { asyncResult: true }, | ||
loadUsers: { asyncResult: true }, | ||
load: { asyncResult: true }, | ||
deleteUser: { asyncResult: true }, | ||
changePassword: { asyncResult: true }, | ||
update: { asyncResult: true }, | ||
createToken: { asyncResult: true }, | ||
deleteToken: { asyncResult: true }, | ||
loadTokens: { asyncResult: true }, | ||
}), | ||
); | ||
|
||
export default UsersActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
// @flow strict | ||
import * as React from 'react'; | ||
|
||
import type { User } from 'stores/users/UsersStore'; | ||
import type { UserJSON } from 'logic/users/User'; | ||
|
||
import { singleton } from '../views/logic/singleton'; | ||
|
||
const CurrentUserContext = React.createContext<?User>(); | ||
const CurrentUserContext = React.createContext<?UserJSON>(); | ||
|
||
export default singleton('contexts.CurrentUserContext', () => CurrentUserContext); |
Oops, something went wrong.