Skip to content

Commit

Permalink
Removing the credentials info from the pop-up form.
Browse files Browse the repository at this point in the history
  • Loading branch information
laceysanderson committed Jul 24, 2024
1 parent ee81376 commit 60edb70
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 39 deletions.
49 changes: 13 additions & 36 deletions src/DrupalRestAuthModel/DrupalRestAuthLoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,65 +1,42 @@
import React, { useState } from 'react'
import { Button, DialogContent, DialogActions, TextField } from '@mui/material'
import { Button, DialogContent, DialogActions, TextField, Container } from '@mui/material'
import { Dialog } from '@jbrowse/core/ui'

export function DrupalRestAuthLoginForm({
internetAccountId,
internetAccountName,
internetAccountDescription,
handleClose,
}: {
internetAccountId: string
internetAccountName: string
internetAccountDescription: string
handleClose: (arg?: string) => void
}) {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')
// const [username, setUsername] = useState('')
// const [password, setPassword] = useState('')

return (
<Dialog
open
maxWidth="xl"
data-testid="login-DrupalRestAuth"
title={`Log in for ${internetAccountId}`}
title={`${internetAccountName}`}
>
<form
onSubmit={event => {
if (username && password) {
handleClose(btoa(`${username}:${password}`))
} else {
handleClose()
}
handleClose(btoa(`not:needed`))
event.preventDefault()
}}
>
<DialogContent style={{ display: 'flex', flexDirection: 'column' }}>
<TextField
required
label="Username"
variant="outlined"
inputProps={{ 'data-testid': 'login-DrupalRestAuth-username' }}
onChange={event => setUsername(event.target.value)}
margin="dense"
/>
<TextField
required
label="Password"
type="password"
autoComplete="current-password"
variant="outlined"
inputProps={{ 'data-testid': 'login-DrupalRestAuth-password' }}
onChange={event => setPassword(event.target.value)}
margin="dense"
/>
<Container>
{internetAccountDescription}
</Container>
</DialogContent>
<DialogActions>
<Button variant="contained" color="primary" type="submit">
Submit
</Button>
<Button
variant="contained"
color="secondary"
type="submit"
onClick={() => handleClose()}
>
Cancel
Continue
</Button>
</DialogActions>
</form>
Expand Down
2 changes: 1 addition & 1 deletion src/DrupalRestAuthModel/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const DrupalRestConfigSchema = ConfigurationSchema(
'DrupalRestAuthInternetAccount',
{
/**
* #slot
* #slot The URI of the Drupal REST API
*/
drupalUri: {
description: 'The base URL for the Drupal site we want to authenticate against.',
Expand Down
4 changes: 2 additions & 2 deletions src/DrupalRestAuthModel/model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ const stateModelFactory = (
DrupalRestAuthLoginForm,
{
internetAccountId: self.internetAccountId,
internetAccountName: self.name,
internetAccountDescription: self.description,
handleClose: (token: string) => {
if (token) {
resolve(token)
Expand All @@ -94,8 +96,6 @@ const stateModelFactory = (
}

const checkLoginStatusUri = self.drupalUri + "user/login_status?_format=json"
console.log(checkLoginStatusUri)
const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token)
const response = await fetch(checkLoginStatusUri)
if (!response.ok) {
throw new Error(
Expand Down

0 comments on commit 60edb70

Please sign in to comment.