1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-12 11:54:35 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
semantic-release-bot
afff27fd21 chore(release): 0.3.4 [skip ci]
## [0.3.4](https://github.com/sasjs/server/compare/v0.3.3...v0.3.4) (2022-05-30)

### Bug Fixes

* **web:** system username for DESKTOP mode ([a8ba378](a8ba378fd1))
2022-05-30 16:12:22 +00:00
Saad Jutt
a8ba378fd1 fix(web): system username for DESKTOP mode 2022-05-30 21:08:17 +05:00
4 changed files with 30 additions and 3 deletions

View File

@@ -1,3 +1,10 @@
## [0.3.4](https://github.com/sasjs/server/compare/v0.3.3...v0.3.4) (2022-05-30)
### Bug Fixes
* **web:** system username for DESKTOP mode ([a8ba378](https://github.com/sasjs/server/commit/a8ba378fd1ff374ba025a96fdfae5c6c36954465))
## [0.3.3](https://github.com/sasjs/server/compare/v0.3.2...v0.3.3) (2022-05-30) ## [0.3.3](https://github.com/sasjs/server/compare/v0.3.2...v0.3.3) (2022-05-30)

View File

@@ -1,4 +1,5 @@
import { RequestHandler, Request } from 'express' import { RequestHandler, Request } from 'express'
import { userInfo } from 'os'
import { RequestUser } from '../types' import { RequestUser } from '../types'
import { ModeType } from '../utils' import { ModeType } from '../utils'
@@ -29,8 +30,8 @@ export const desktopRestrict: RequestHandler = (req, res, next) => {
export const desktopUser: RequestUser = { export const desktopUser: RequestUser = {
userId: 12345, userId: 12345,
clientId: 'desktop_app', clientId: 'desktop_app',
username: 'DESKTOPusername', username: userInfo().username,
displayName: 'DESKTOP User', displayName: userInfo().username,
isAdmin: true, isAdmin: true,
isActive: true isActive: true
} }

View File

@@ -16,7 +16,7 @@ import {
} from '@mui/material' } from '@mui/material'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { AppContext } from '../../context/appContext' import { AppContext, ModeType } from '../../context/appContext'
const Profile = () => { const Profile = () => {
const [isLoading, setIsLoading] = useState(false) const [isLoading, setIsLoading] = useState(false)
@@ -89,6 +89,7 @@ const Profile = () => {
required required
value={user.displayName} value={user.displayName}
variant="outlined" variant="outlined"
disabled={appContext.mode === ModeType.Desktop}
/> />
</Grid> </Grid>
@@ -103,6 +104,7 @@ const Profile = () => {
required required
value={user.username} value={user.username}
variant="outlined" variant="outlined"
disabled={appContext.mode === ModeType.Desktop}
/> />
</Grid> </Grid>

View File

@@ -9,6 +9,11 @@ import React, {
} from 'react' } from 'react'
import axios from 'axios' import axios from 'axios'
export enum ModeType {
Server = 'server',
Desktop = 'desktop'
}
interface AppContextProps { interface AppContextProps {
checkingSession: boolean checkingSession: boolean
loggedIn: boolean loggedIn: boolean
@@ -19,6 +24,7 @@ interface AppContextProps {
setUsername: Dispatch<SetStateAction<string>> | null setUsername: Dispatch<SetStateAction<string>> | null
displayName: string displayName: string
setDisplayName: Dispatch<SetStateAction<string>> | null setDisplayName: Dispatch<SetStateAction<string>> | null
mode: ModeType
logout: (() => void) | null logout: (() => void) | null
} }
@@ -32,6 +38,7 @@ export const AppContext = createContext<AppContextProps>({
setUsername: null, setUsername: null,
displayName: '', displayName: '',
setDisplayName: null, setDisplayName: null,
mode: ModeType.Server,
logout: null logout: null
}) })
@@ -42,6 +49,7 @@ const AppContextProvider = (props: { children: ReactNode }) => {
const [userId, setUserId] = useState(0) const [userId, setUserId] = useState(0)
const [username, setUsername] = useState('') const [username, setUsername] = useState('')
const [displayName, setDisplayName] = useState('') const [displayName, setDisplayName] = useState('')
const [mode, setMode] = useState(ModeType.Server)
useEffect(() => { useEffect(() => {
setCheckingSession(true) setCheckingSession(true)
@@ -60,6 +68,14 @@ const AppContextProvider = (props: { children: ReactNode }) => {
setLoggedIn(false) setLoggedIn(false)
axios.get('/') // get CSRF TOKEN axios.get('/') // get CSRF TOKEN
}) })
axios
.get('/SASjsApi/info')
.then((res) => res.data)
.then((data: any) => {
setMode(data.mode)
})
.catch(() => {})
}, []) }, [])
const logout = useCallback(() => { const logout = useCallback(() => {
@@ -82,6 +98,7 @@ const AppContextProvider = (props: { children: ReactNode }) => {
setUsername, setUsername,
displayName, displayName,
setDisplayName, setDisplayName,
mode,
logout logout
}} }}
> >