diff --git a/components/Books.js b/components/Books.js index c3b0ce8..a05c9c2 100644 --- a/components/Books.js +++ b/components/Books.js @@ -210,7 +210,10 @@ class Books extends React.Component { }); let url = ""; + let Identifier = this.state.IAIdentifier; + console.log(Identifier); const isAlphanumericLess50 = /^(?=.*[a-zA-Z])(?=.*[0-9])[a-zA-Z0-9]{1,50}$/; + const isAlphabetUniqueLess50 = /^[a-zA-Z0-9]{1,50}$/; switch (this.state.option) { case "gb": url = `${host}/check?bookid=${this.state.bookid}&option=${ @@ -220,6 +223,7 @@ class Books extends React.Component { fetch(url) .then((response) => response.json()) .then(async (response) => { + console.log("Response from the server:", response); this.setState({ loader: false, }); @@ -232,9 +236,11 @@ class Books extends React.Component { } else if (!isAlphanumericLess50.test(response.IAIdentifier)) { this.setState({ isValidIdentifier: false, - IATitle: response.IAIdentifier, + //IATitle: response.IAIdentifier, + IATitle: response.titleInIA, inputDisabled: true, }); + console.log(response.IAIdentifier); } else { if (response.error) { Swal("Error!", response.message, "error"); @@ -314,9 +320,12 @@ class Books extends React.Component { }&categoryID=${categoryID}&userName=${userName}&IAtitle=${ this.state.IAIdentifier }`; + + console.log(url); fetch(url) .then((res) => res.json()) .then((response) => { + console.log("Response from the server:", response); this.setState({ loader: false, }); @@ -326,10 +335,12 @@ class Books extends React.Component { IATitle: response.titleInIA, inputDisabled: true, }); - } else if (!isAlphanumericLess50.test(response.IAIdentifier)) { + } else if (!isAlphabetUniqueLess50.test(response.IAIdentifier)) { + console.log("IAIdentifier:", response.IAIdentifier); this.setState({ isValidIdentifier: false, - IATitle: response.IAIdentifier, + //IATitle: response.IAIdentifier, + IATitle: response.titleInIA, inputDisabled: true, }); } else { @@ -434,7 +445,7 @@ class Books extends React.Component { (0-9). } - inputPlaceholder="Enter a valid Identifier that is less than 50 characters and Alphanumeric" + inputPlaceholder="Enter a valid Identifier" onIdentifierChange={(event) => this.setState({ IAIdentifier: event.target.value }) } diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index ce47fd1..debfaa3 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -7,8 +7,17 @@ export const authOptions = { providers: [ WikimediaProvider({ clientId: process.env.WIKIMEDIA_CLIENT_ID, - clientSecret: process.env.WIKIMEDIA_CLIENT_SECRET - }) + clientSecret: process.env.WIKIMEDIA_CLIENT_SECRET, + authorization: { + url: + "https://meta.wikimedia.beta.wmflabs.org/w/rest.php/oauth2/authorize", + params: { scope: "" }, + }, + token: + "https://meta.wikimedia.beta.wmflabs.org//w/rest.php/oauth2/access_token", + userinfo: + "https://meta.wikimedia.beta.wmflabs.org//w/rest.php/oauth2/resource/profile", + }), ], session: { jwt: true, diff --git a/server.js b/server.js index 8f0a799..c80e288 100644 --- a/server.js +++ b/server.js @@ -440,6 +440,7 @@ app } else { res.send({ error: false, + IAIdentifier: titleInIA, message: "You will be mailed with the details soon!", }); PDLProducer(bookid, titleInIA, categoryID, email, authUserName);