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

Compare commits

...

5 Commits

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

### Bug Fixes

* bumping sasjs/core library ([61815f8](61815f8ae1))
2022-05-30 18:07:50 +00:00
Allan Bowe
576e18347e Merge pull request #182 from sasjs/bumpcore
fix: bumping sasjs/core library
2022-05-30 21:02:59 +03:00
Allan Bowe
61815f8ae1 fix: bumping sasjs/core library 2022-05-30 18:02:30 +00:00
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
6 changed files with 45 additions and 11 deletions

View File

@@ -1,3 +1,17 @@
## [0.3.5](https://github.com/sasjs/server/compare/v0.3.4...v0.3.5) (2022-05-30)
### Bug Fixes
* bumping sasjs/core library ([61815f8](https://github.com/sasjs/server/commit/61815f8ae18be132e17c199cd8e3afbcc2fa0b60))
## [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)

14
api/package-lock.json generated
View File

@@ -8,7 +8,7 @@
"name": "api", "name": "api",
"version": "0.0.2", "version": "0.0.2",
"dependencies": { "dependencies": {
"@sasjs/core": "^4.23.1", "@sasjs/core": "^4.27.3",
"@sasjs/utils": "2.42.1", "@sasjs/utils": "2.42.1",
"bcryptjs": "^2.4.3", "bcryptjs": "^2.4.3",
"connect-mongo": "^4.6.0", "connect-mongo": "^4.6.0",
@@ -1385,9 +1385,9 @@
} }
}, },
"node_modules/@sasjs/core": { "node_modules/@sasjs/core": {
"version": "4.23.1", "version": "4.27.3",
"resolved": "https://registry.npmjs.org/@sasjs/core/-/core-4.23.1.tgz", "resolved": "https://registry.npmjs.org/@sasjs/core/-/core-4.27.3.tgz",
"integrity": "sha512-9d6yEPJRRvPLMUkpyaiQ62SXNMMyt2l815jxWgFjnVOxKeUQv9TPyZqZ0FpmWdVe6EY8dv8GLlyaBpOLDnY6Vg==" "integrity": "sha512-8AaPPRGMwhmjw244CDSnTqHXdp/77ZBjIJMgwqw4wTrCf8Vzs2Y5hVihbvAniIGQctZHLMR6X5a3X4ccn9gRjg=="
}, },
"node_modules/@sasjs/utils": { "node_modules/@sasjs/utils": {
"version": "2.42.1", "version": "2.42.1",
@@ -11364,9 +11364,9 @@
} }
}, },
"@sasjs/core": { "@sasjs/core": {
"version": "4.23.1", "version": "4.27.3",
"resolved": "https://registry.npmjs.org/@sasjs/core/-/core-4.23.1.tgz", "resolved": "https://registry.npmjs.org/@sasjs/core/-/core-4.27.3.tgz",
"integrity": "sha512-9d6yEPJRRvPLMUkpyaiQ62SXNMMyt2l815jxWgFjnVOxKeUQv9TPyZqZ0FpmWdVe6EY8dv8GLlyaBpOLDnY6Vg==" "integrity": "sha512-8AaPPRGMwhmjw244CDSnTqHXdp/77ZBjIJMgwqw4wTrCf8Vzs2Y5hVihbvAniIGQctZHLMR6X5a3X4ccn9gRjg=="
}, },
"@sasjs/utils": { "@sasjs/utils": {
"version": "2.42.1", "version": "2.42.1",

View File

@@ -47,7 +47,7 @@
}, },
"author": "4GL Ltd", "author": "4GL Ltd",
"dependencies": { "dependencies": {
"@sasjs/core": "^4.23.1", "@sasjs/core": "^4.27.3",
"@sasjs/utils": "2.42.1", "@sasjs/utils": "2.42.1",
"bcryptjs": "^2.4.3", "bcryptjs": "^2.4.3",
"connect-mongo": "^4.6.0", "connect-mongo": "^4.6.0",

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
}} }}
> >