Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions components/Books.js
Original file line number Diff line number Diff line change
Expand Up @@ -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=${
Expand All @@ -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,
});
Expand All @@ -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");
Expand Down Expand Up @@ -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,
});
Expand All @@ -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 {
Expand Down Expand Up @@ -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 })
}
Expand Down
13 changes: 11 additions & 2 deletions pages/api/auth/[...nextauth].js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down