mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-26 21:26:01 -05:00
fixed user page bug displaying twitter at incorrect times
This commit is contained in:
25
index.js
25
index.js
@@ -229,6 +229,10 @@ const typeDefs = gql`
|
||||
username: String!
|
||||
password: String!
|
||||
): Token
|
||||
updateTwitter(
|
||||
unique_id: String!
|
||||
twitter: String!
|
||||
): Boolean
|
||||
addBuild(
|
||||
weapon: String!
|
||||
title: String
|
||||
@@ -239,6 +243,9 @@ const typeDefs = gql`
|
||||
deleteBuild(
|
||||
id: ID!
|
||||
): Boolean
|
||||
updateBuild(
|
||||
build: Build!
|
||||
): Boolean
|
||||
}
|
||||
`
|
||||
|
||||
@@ -598,6 +605,23 @@ const resolvers = {
|
||||
}
|
||||
},
|
||||
Mutation: {
|
||||
editTwitter: async (root, args, ctx) => {
|
||||
if (!ctx.user.id !== PROCESS.ENV.ADMIN_ID) throw new AuthenticationError('not admin')
|
||||
|
||||
const player = await Player.findOne({ unique_id: args.unique_id })
|
||||
|
||||
player.twitter = args.twitter.toLowerCase()
|
||||
|
||||
try {
|
||||
await player.save()
|
||||
} catch (error) {
|
||||
throw new UserInputError(error.message, {
|
||||
invalidArgs: args,
|
||||
})
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
addBuild: async (root, args, ctx) => {
|
||||
if (!ctx.user) throw new AuthenticationError('User not logged in.')
|
||||
if (args.title) if (args.title.length > 100) throw new UserInputError('Title too long.', {
|
||||
@@ -646,6 +670,7 @@ const resolvers = {
|
||||
},
|
||||
Player: {
|
||||
discord_id: async (root) => {
|
||||
if (!root.twitter) return null
|
||||
const user = await User
|
||||
.findOne({ twitter_name: root.twitter })
|
||||
.catch(e => {
|
||||
|
||||
0
react-ui/src/components/Misc/Admin.js
vendored
Normal file
0
react-ui/src/components/Misc/Admin.js
vendored
Normal file
@@ -15,10 +15,14 @@ const UserPage = ({ userIdOrName }) => {
|
||||
return <div style={{"paddingTop": "25px", "paddingBottom": "20000px"}} ><Loader active inline='centered' /></div>
|
||||
}
|
||||
|
||||
if (error || userLeanQuery.loading) {
|
||||
if (error) {
|
||||
return <div style={{"color": "red"}}>{error.message}</div>
|
||||
}
|
||||
|
||||
if (userLeanQuery.error) {
|
||||
return <div style={{"color": "red"}}>{userLeanQuery.error.message}</div>
|
||||
}
|
||||
|
||||
const userData = data.searchForUser
|
||||
if (!userData) return <Redirect to='/404' />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user