(props: { readonly children: React.ReactNode })
| 148 | * shell. |
| 149 | */ |
| 150 | export function LocalAuthGate(props: { readonly children: React.ReactNode }) { |
| 151 | const required = useAuthRequired(); |
| 152 | const [value, setValue] = React.useState(""); |
| 153 | |
| 154 | if (!required) return <>{props.children}</>; |
| 155 | |
| 156 | return ( |
| 157 | <div className="flex h-screen items-center justify-center bg-background p-6"> |
| 158 | <form |
| 159 | className="flex w-full max-w-sm flex-col gap-3 rounded-xl border border-border bg-card p-6 shadow-sm" |
| 160 | onSubmit={(event) => { |
| 161 | event.preventDefault(); |
| 162 | setLocalAuthToken(value); |
| 163 | }} |
| 164 | > |
| 165 | <h1 className="text-base font-semibold text-foreground">Authentication required</h1> |
| 166 | <p className="text-sm text-muted-foreground"> |
| 167 | Run <code>executor open</code> in your terminal to sign in, or paste the server's token |
| 168 | below. |
| 169 | </p> |
| 170 | {/* oxlint-disable-next-line react/forbid-elements -- token entry input */} |
| 171 | <input |
| 172 | type="password" |
| 173 | autoFocus |
| 174 | value={value} |
| 175 | onChange={(event) => setValue(event.target.value)} |
| 176 | placeholder="Bearer token" |
| 177 | className="rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary" |
| 178 | /> |
| 179 | {/* oxlint-disable-next-line react/forbid-elements -- gate submit button */} |
| 180 | <button |
| 181 | type="submit" |
| 182 | disabled={value.trim().length === 0} |
| 183 | className="rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50" |
| 184 | > |
| 185 | Connect |
| 186 | </button> |
| 187 | </form> |
| 188 | </div> |
| 189 | ); |
| 190 | } |
nothing calls this directly
no test coverage detected