Skip to content

Commit

Permalink
[Tech] User credentials are no longer stored in plain text
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidgarus committed Mar 30, 2022
1 parent 0b60a27 commit eb999df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
17 changes: 14 additions & 3 deletions electron/legendary/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, readFileSync } from 'graceful-fs'
import { existsSync, readFile } from 'graceful-fs'

import { UserInfo } from '../types'
import { clearCache } from '../utils'
Expand Down Expand Up @@ -57,8 +57,19 @@ export class LegendaryUser {

public static async getUserInfo(): Promise<UserInfo> {
if (LegendaryUser.isLoggedIn()) {
const info = {
...JSON.parse(readFileSync(userInfo, 'utf-8')),
const userInfoContent = await new Promise<string>((resolve, reject) => {
readFile(userInfo, 'utf-8', (err, content) => {
if (err) {
reject(err)
} else {
resolve(content)
}
})
})
const userInfoObject = JSON.parse(userInfoContent)
const info: UserInfo = {
account_id: userInfoObject.account_id,
displayName: userInfoObject.displayName,
user: user().username
}
configStore.set('userInfo', info)
Expand Down
1 change: 1 addition & 0 deletions electron/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export type UserInfo = {
displayName?: string
epicId?: string
name?: string
user?: string
}
export interface WineInstallation {
bin: string
Expand Down
4 changes: 2 additions & 2 deletions src/state/GlobalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ export class GlobalState extends PureComponent<Props> {
const { libraryStatus } = this.state
this.handleGameStatus({ ...libraryStatus, ...args })
})
const legendaryUser = configStore.get('userInfo')
const gogUser = gogConfigStore.get('userData')
const legendaryUser = Boolean(configStore.get('userInfo'))
const gogUser = Boolean(gogConfigStore.get('userData'))
const platform = await getPlatform()
const category = storage.getItem('category') || 'epic'
const filter = storage.getItem('filter') || 'all'
Expand Down

0 comments on commit eb999df

Please sign in to comment.