Please help me with this code is correct but still otp is not getting verified even i checked otp from cookie as well received otp both gets match - cookies

Please help me with this code... when i write wrong otp still it shows registration succesful.
if(isset($_POST['verifyotp'])) {
$otp = $_POST['otp'];
if($_COOKIE['otp'] == $otp) {
echo "Registration Successfull.";
} else {
echo "Wrong OTP";
}
}

Related

getaddrinfo: xxURL get result from proxy gai_error = 0

Im building a flutter application which uses django ad back-end. using signup api endpoint. the
api shows error 200 from the logs but signup doesnt go through.
the logs
D/libc-netbsd( 8600): getaddrinfo: hookie-twitter.herokuapp.com get result from proxy gai_error = 0
I/flutter ( 8600): 200
sign up service
Future<int> authUserSignup(String username, String password,
String email) async {
http.Response response = await http.post(
signUpUrl,
body: {
"username": username,
// "phone":phone,
"password": password,
"email": email,
}
);
print(response.statusCode);
return response.statusCode;
}
on signup onClicK
_pressCreateAccountButton(){
//TO DO: MOVE TO VERIFY PHONE SECTION
var signMeUp = connectSigninApi.authUserSignup(editControllerName.text, editControllerEmail.text, editControllerPassword2.text);
if(signMeUp == 200){
if(_globalformkey.currentState.validate() && matchesEmail.hasMatch(editControllerEmail.text)){
if(editControllerPassword1.text == editControllerPassword2.text){
print("User pressed \"CREATE ACCOUNT\" button");
print("Login: ${editControllerName.text}, E-mail: ${editControllerEmail.text}, "
"password1: ${editControllerPassword1.text}, password2: ${editControllerPassword2.text}");
route.push(context, "/sendphone");
Toast.show('sign successrgb',context,gravity: Toast.BOTTOM);
}
}
}
else{
Toast.show('sign failedbik',context,gravity: Toast.BOTTOM);
}
}
HTTP response "200" only indicates that the request has succeeded. It's best to check the logs of the backend to see if a response has been made. The log with getaddrinfo seems to be a warning and doesn't provide enough details for us to work with. Check what the response.body contains if there's any meaningful results.
But glancing at your code snippet, it seems that you just need to add await when Future has been set to the var.
var signMeUp = await connectSigninApi.authUserSignup(...)
Without await, the method will be called but it won't wait for the result.

AWS Amplify Auth Errors

I'm using the Android Amplify library. I am having trouble finding out what kind of error would be passed back from the Amplify.Auth.signIn() function. I'm not finding the documentation for this anywhere. Right now I am just kind of guessing as to what it will return. What I want is to tell the user how to recover from the error. Does the username not exist, was the password incorrect, was it of bad format, etc. Reading the source code I am given the impression that AmplifyException.recoveryMessage is what I want but that would still be problematic as it doesn't allow me to customize the message.
/**
* Sign in the user to the back-end service and set the currentUser for this application
* #param username User's username
* #param password User's password
*/
override fun initiateSignin(username : String, password : String) {
//Sign in the user to the AWS back-end
Amplify.Auth.signIn(
username,
password,
{result ->
if (result.isSignInComplete) {
Timber.tag(TAG).i("Sign in successful.")
//Load the user if the sign in was successful
loadUser()
} else {
Timber.tag(TAG).i("Sign in unsuccessful.")
//TODO: I think this will happen if the password is incorrect?
}
},
{error ->
Timber.tag(UserLogin.TAG).e(error.toString())
authenticationRecoveryMessage.value = error.recoverySuggestion
}
)
}
Authentication recovery message is LiveData that I want to update a snackbar which will tell the user what they need to do for a successful login. I feel there must be some way to get the error from this that I just haven't figured out yet. The ideal way to handle messages to the user is with XML strings for translation possibilities so I would really like to use my own strings in the snackbar but I need to know the things that can go wrong with sign-up and what is being communicated to me through the error -> {} callback.
I couldn't find them in the documentation myself, so i decided to log the possibles cases.
try {
const signInResult = await Auth.signIn({
username: emailOrPhoneNumber,
password
});
const userId = signInResult.attributes.sub;
const token = (await Auth.currentSession()).getAccessToken().getJwtToken();
console.log(userId, 'token: ', token);
resolve(new AuthSession(userId, token, false));
} catch (e) {
switch (e.message) {
case 'Username should be either an email or a phone number.':
reject(`${AuthError.usernameInvalid}: ${e.message}`);
break;
case 'Password did not conform with policy: Password not long enough':
reject(`${AuthError.passwordTooShort}: ${e.message}`);
break;
case 'User is not confirmed.':
reject(`${AuthError.userIsNotConfirmed}: ${e.message}`);
break;
case 'Incorrect username or password.':
reject(`${AuthError.incorrectUsernameOrPassword}: ${e.message}`);
break;
case 'User does not exist.':
reject(`${AuthError.userDoesNotExist}: ${e.message}`);
break;
default:
reject(`${AuthError.unknownError}: ${e.message}`);
}
}
SignIn uses Cognito's InitiateAuth under the hood, so error codes can be found here:
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html#API_InitiateAuth_Errors
They are available in the code field of the error.

What is "cognitoUser.getAttributeVerificationCode"?

I'm convinced that Amazon goes out of its way to make understanding their platform as difficult as is possible.
I've read over the documentation regarding "cognitoUser.getAttributeVerificationCode" at Amazon only to have it make me even more confused!
Verify an Attribute
The following example verifies user attributes for an authenticated user.
cognitoUser.getAttributeVerificationCode('email', {
onSuccess: function (result) {
console.log('call result: ' + result);
},
onFailure: function(err) {
alert(err);
},
inputVerificationCode: function() {
var verificationCode = prompt('Please input verification code: ' ,'');
cognitoUser.verifyAttribute('email', verificationCode, this);
}
});
Can anyone help me understand what this is (cognitoUser.getAttributeVerificationCode) and/or how I would use it? I don't understand why I would verify an email attribute w/a verification code.
The verification code is sent to the users email. The user has to properly receive that email to retrieve the code and enter it in a UI so that the email is set to verified in Cognito. That user can then reset their password using that email.
What if the user had entered an incorrect email? Or their email system didn't allow them to receive the code sent by AWS?
By sending out a verification code, and having the user send it back, Cognito verifies that the email was entered correctly and belongs to that user. This can seem like a pain but is standard on many web platforms now days...The same process is needed with phone numbers for users in your Cognito user pool.

Allow "-" (hyphen) before # symbol for email validation

I am working on email validation for a asp.net server control.
Below are the sample emails system should allow -
test#domain.com
test#domain.subdomain.com
v-test#domain.com
v-test#domain.subdomain.com
Can anyone please tell me how to write a regular expression for the above email validation.
Here is my code working correctly for simple emails like test#domain.com etc
var emailPat = /^(\".*\"|[A-Za-z]\w*)#(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/
var EmailmatchArray = UserEmail.match(emailPat);
if (EmailmatchArray == null) {
document.getElementById('<%=lblEmailErrorCtrl.ClientID%>').innerText = "Invalid email address";
return false;
}
Note that this will not magically validate all valid emails - that task is nearly impossible. To fix your situation though, try:
var emailPat = /^(\".\"|[-A-Za-z]\w)#([\d{1,3}(.\d{1,3}){3}]|[A-Za-z]\w*(.[A-Za-z]\w*)+)$/

getting the information if the user is a fan of a page

I have a problem with getting the information if the user is a fan of a page (fanpage) becouse sometimes this query
SELECT uid FROM page_fan WHERE uid=$mUserId AND page_id=$iPageId
gets me an empty result although the user is a fan of the page
I used this JavaScript method which returned me "resp.error_code" and "resp.error_msg" was "Invalid API key"
FB.api({
method: 'pages.isFan',
page_id: 'FB_FAN_PAGE_ID',
uid: $iUser
}, function (resp) {
if (resp == true) {
alert('fan');
} else if (resp.error_code) {
alert(resp.error_msg);
} else {
alert('no-fan');
}
});
but the code is correct as the application starts and what is strange it sometimes works and sometimes doesn't work.
I try to get the user is fan form request just like in this post How to check if a user likes my Facebook Page or URL using Facebook's API but it doesn't work.
Help pleace
With JS SDK you can check if the currently logged-in user has liked a page like this:
FB.api("me/likes/" + appPageId, function(response) {
if(response && response.data[0]) {
//user has liked the page
} else {
//user has not like the page
}
});