forked from curityio/react-haapi-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SME-912] support business token flow (#30)
This is related to curity [PR here](TransferGo/curity-server#408) and [qa-tests PR](TransferGo/qa-test#1043) Support new authentication actions. Modified login screen to allow selecting which scopes to request after authentication.
- Loading branch information
1 parent
a720037
commit 62f7241
Showing
6 changed files
with
96 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,55 @@ | ||
/* | ||
* Copyright 2022 Curity AB | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { useState } from "react"; | ||
|
||
export default function StartAuthorization(props) { | ||
const { startAuthorization } = props | ||
const { startAuthorization } = props; | ||
|
||
return <> | ||
<button onClick={startAuthorization} className="button button-primary button-fullwidth" id="submit" data-qa="start">Login</button> | ||
</> | ||
const [scopes, setScopes] = useState(new Set(["openid", "user"])); | ||
|
||
const onChange = (name, checked) => { | ||
if (checked) scopes.add(name); | ||
else scopes.delete(name); | ||
const newSet = new Set(Array.from(scopes)); | ||
setScopes(newSet); | ||
}; | ||
|
||
return ( | ||
<div className="login-container"> | ||
<h3>Select scopes</h3> | ||
<Checkbox | ||
name="openid" | ||
checked={scopes.has("openid")} | ||
onChange={onChange} | ||
/> | ||
<Checkbox name="user" checked={scopes.has("user")} onChange={onChange} /> | ||
<Checkbox | ||
name="business" | ||
checked={scopes.has("business")} | ||
onChange={onChange} | ||
/> | ||
<button | ||
onClick={() => startAuthorization(Array.from(scopes).join(" "))} | ||
className="button button-primary button-fullwidth" | ||
id="submit" | ||
data-qa="start" | ||
> | ||
Login | ||
</button> | ||
</div> | ||
); | ||
} | ||
|
||
const Checkbox = ({ name, checked, onChange }) => { | ||
return ( | ||
<div> | ||
<label htmlFor={name} className="label"> | ||
{name} | ||
</label> | ||
<input | ||
name={name} | ||
type="checkbox" | ||
checked={checked} | ||
onChange={(event) => onChange(name, event.target.checked)} | ||
/> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters