mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-10 12:50:29 +08:00
Add frontend getOAuthCode() API.
This commit is contained in:
@@ -71,9 +71,9 @@ func (c *ApiController) DeleteToken() {
|
|||||||
|
|
||||||
func (c *ApiController) GetOAuthCode() {
|
func (c *ApiController) GetOAuthCode() {
|
||||||
userId := c.GetSessionUser()
|
userId := c.GetSessionUser()
|
||||||
clientId := c.Input().Get("client_id")
|
clientId := c.Input().Get("clientId")
|
||||||
responseType := c.Input().Get("response_type")
|
responseType := c.Input().Get("responseType")
|
||||||
redirectUri := c.Input().Get("redirect_uri")
|
redirectUri := c.Input().Get("redirectUri")
|
||||||
scope := c.Input().Get("scope")
|
scope := c.Input().Get("scope")
|
||||||
state := c.Input().Get("state")
|
state := c.Input().Get("state")
|
||||||
|
|
||||||
|
@@ -51,6 +51,13 @@ export function authLogin(applicationName, providerName, code, state, redirectUr
|
|||||||
}).then(res => res.json());
|
}).then(res => res.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getOAuthCode(clientId, responseType, redirectUri, scope, state) {
|
||||||
|
return fetch(`${authConfig.serverUrl}/api/oauth/code?clientId=${clientId}&responseType=${responseType}&redirectUri=${redirectUri}&scope=${scope}&state=${state}`, {
|
||||||
|
method: 'GET',
|
||||||
|
credentials: 'include',
|
||||||
|
}).then(res => res.json());
|
||||||
|
}
|
||||||
|
|
||||||
export function getApplication(owner, name) {
|
export function getApplication(owner, name) {
|
||||||
return fetch(`${authConfig.serverUrl}/api/get-application?id=${owner}/${encodeURIComponent(name)}`, {
|
return fetch(`${authConfig.serverUrl}/api/get-application?id=${owner}/${encodeURIComponent(name)}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
@@ -22,10 +22,16 @@ import * as Util from "./Util";
|
|||||||
class Face extends React.Component {
|
class Face extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
const queries = new URLSearchParams(window.location.search);
|
||||||
this.state = {
|
this.state = {
|
||||||
classes: props,
|
classes: props,
|
||||||
applicationName: props.applicationName !== undefined ? props.applicationName : (props.match === undefined ? null : props.match.params.applicationName),
|
applicationName: props.applicationName !== undefined ? props.applicationName : (props.match === undefined ? null : props.match.params.applicationName),
|
||||||
application: null,
|
application: null,
|
||||||
|
clientId: queries.get("client_id"),
|
||||||
|
responseType: queries.get("response_type"),
|
||||||
|
redirectUri: queries.get("redirect_uri"),
|
||||||
|
scope: queries.get("scope"),
|
||||||
|
state: queries.get("state"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,6 +182,9 @@ class Face extends React.Component {
|
|||||||
{
|
{
|
||||||
this.renderLogo(application)
|
this.renderLogo(application)
|
||||||
}
|
}
|
||||||
|
{/*{*/}
|
||||||
|
{/* this.state.clientId !== null ? "Redirect" : null*/}
|
||||||
|
{/*}*/}
|
||||||
{
|
{
|
||||||
this.renderForm(application)
|
this.renderForm(application)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user