Commit e5fb5b49 authored by ruvisenarthna's avatar ruvisenarthna

Update verification screen

parent 9b5a26ae
......@@ -8,6 +8,8 @@ android {
defaultConfig {
applicationId "com.elearning.probabilityandstatisticsanalyserandeducator"
multiDexEnabled true
python{
pip{
install "numpy"
......@@ -38,7 +40,7 @@ android {
// python.exe file path *********** please change this according to your file path
python{
buildPython "C:/Users/Navod/AppData/Local/Programs/Python/Python39/python.exe"
buildPython "C:/Users/Ruvi/AppData/Local/Programs/Python/Python39/python.exe"
}
}
......@@ -73,6 +75,9 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation files('libs\\activation.jar')
implementation files('libs\\mail.jar')
implementation files('libs\\additional.jar')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
......@@ -83,7 +88,8 @@ dependencies {
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
implementation 'com.opencsv:opencsv:4.6'
implementation 'com.alimuzaffar.lib:pinentryedittext:1.3.1'
implementation 'androidx.multidex:multidex:2.0.1'
......
......@@ -45,6 +45,7 @@
<activity android:name=".QuestionTypes" />
<activity android:name=".Welcome" />
<activity android:name=".SignUp" />
<activity android:name=".verification_screen" />
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar" >
......
......@@ -223,11 +223,6 @@ public class Sign_up_part3 extends AppCompatActivity {
}
}
return z;
}
}
......
......@@ -116,7 +116,7 @@ public class Welcome extends AppCompatActivity {
if (con == null) {
z = "Check your Internet Connection";
} else {
String query = "select * from User_Table where userName = '" + uName.toString() + "' and password = '" + upassword.toString() + "' and is_Active = '1'";
String query = "select * from User_Table where userName = '" + uName.toString() + "' and password = '" + upassword.toString() + "' ";
Statement st = con.createStatement();
ResultSet rst = st.executeQuery(query);
......@@ -137,6 +137,7 @@ public class Welcome extends AppCompatActivity {
String status = rst.getString("status");
String anyExperience = rst.getString("anyExperience");
String resonToChoose = rst.getString("resonToChoose");
int is_Active = rst.getInt("is_Active");
//create a session
SessionManager sessionManager = new SessionManager(Welcome.this);
......@@ -144,9 +145,17 @@ public class Welcome extends AppCompatActivity {
anyExperience, resonToChoose);
con.close();
Intent intent = new Intent(Welcome.this, UserDashBoard.class);
startActivity(intent);
finish();
if (is_Active == 1){
Intent intent = new Intent(Welcome.this, UserDashBoard.class);
startActivity(intent);
finish();
}else{
Intent intent = new Intent(Welcome.this, verification_screen.class);
startActivity(intent);
finish();
}
} else {
z = "invalid User Name or Password";
isSuccess = false;
......
......@@ -39,13 +39,16 @@ import javax.mail.internet.MimeMessage;
public class verification_screen extends AppCompatActivity {
String eSubject, eMessage, sEmail, sPassword, eUserEmail;
String eSubject, eMessage, sEmail, sPassword, eUserEmail, UID;
String host = "smtp.gmail.com";
PinEntryEditText pinEntry;
int OTP =0;
DBConnection dbConnection;
Connection con;
Session session;
MimeMessage message;
@SuppressLint("WrongViewCast")
@Override
......@@ -59,33 +62,41 @@ public class verification_screen extends AppCompatActivity {
OTP = myRandom.nextInt(10000);
System.out.println("OTP"+OTP);
//Add OTP number into Session manger
SessionManager sessionManager = new SessionManager(this);
sessionManager.SetUserOTP(OTP);
dbConnection = new DBConnection();
con = dbConnection.getConnection();
//------------------------- Creating Hash Map---------------------------------
HashMap<String,String> userDetails = sessionManager.getUserDetailsFromSession();
//tacking userID from session manager and it come as a string
//we convert userID int by using parseInt and asssin it into userID
eUserEmail = userDetails.get(SessionManager.KEY_EMAIL);
UID = userDetails.get(sessionManager.KEY_UID);
//sender(our system) email credential
sEmail = "probabilitystatitcs.corner@gmail.com";
sEmail = "probabilitystatitics.corner@gmail.com";
sPassword = "admin121";
eSubject = "Please Confirm Your Email Address for Probability and Statistics analyzer and Educator ";
eMessage = Integer.toString(OTP);
//Initialize Properties
Properties properties = new Properties();
Properties properties = System.getProperties();
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.host", "smtp.gmail.com");
properties.put("mail.smtp.user",sEmail);
properties.put("mail.smtp.password",sPassword);
properties.put("mail.smtp.port", "587");
// properties.put("mail.smtp.ssl.trust", "smtp.gmail.com");
//Initialize session
Session session = Session.getInstance(properties, new Authenticator() {
session = Session.getInstance(properties, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(sEmail,sPassword);
......@@ -94,10 +105,13 @@ public class verification_screen extends AppCompatActivity {
try {
//Initialize email content
Message message = new MimeMessage(session);
message = new MimeMessage(session);
//Sender email
message.setFrom(new InternetAddress(sEmail));
InternetAddress[] toAddress = new InternetAddress[eUserEmail.length()];
toAddress[0] = new InternetAddress(eUserEmail);
//Recipient email
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(eUserEmail.trim()));
......@@ -114,9 +128,47 @@ public class verification_screen extends AppCompatActivity {
//send email
new SendMail().execute(message);
pinEntry = (PinEntryEditText) findViewById(R.id.txt_pin_entry);
// if (pinEntry != null) {
pinEntry.setOnPinEnteredListener(new PinEntryEditText.OnPinEnteredListener() {
@Override
public void onPinEntered(CharSequence str) {
if (str.toString().equals(eMessage)) {
try {
String query = "UPDATE dbo.User_Table set is_Active=1 where userID = '"+UID+"'";
Statement st = con.createStatement();
st.executeUpdate(query);
st.close();
}catch (Exception e){
e.printStackTrace();
}
Toast.makeText(verification_screen.this, "SUCCESS", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(verification_screen.this, UserDashBoard.class);
startActivity(intent);
finish();
System.out.println("emessage Success"+eMessage);
} else {
Toast.makeText(verification_screen.this, "FAIL", Toast.LENGTH_SHORT).show();
pinEntry.setText(null);
}
}
});
} catch (MessagingException e) {
e.printStackTrace();
}
}
}
......@@ -139,7 +191,11 @@ public class verification_screen extends AppCompatActivity {
protected String doInBackground(Message... messages) {
try {
//When success
Transport.send(messages[0]);
// Transport.send(messages[0]);
Transport transport = session.getTransport("smtp");
transport.connect(host,sEmail,sPassword);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
System.out.println("success msg.......");
return "Success";
} catch (MessagingException e) {
......@@ -175,53 +231,12 @@ public class verification_screen extends AppCompatActivity {
//show alert dialog
builder.show();
}else{
//when error
//when error comes
Toast.makeText(getApplicationContext(),
"Something went Wrong..........",Toast.LENGTH_LONG).show();
}
pinEntry = (PinEntryEditText) findViewById(R.id.txt_pin_entry);
if (pinEntry != null) {
pinEntry.setOnPinEnteredListener(new PinEntryEditText.OnPinEnteredListener() {
@Override
public void onPinEntered(CharSequence str) {
if (str.toString().equals(eMessage)) {
Toast.makeText(verification_screen.this, "SUCCESS", Toast.LENGTH_SHORT).show();
System.out.println("emessage Success"+eMessage);
QuizDbHelper quizDbHelper = new QuizDbHelper();
try {
//-------- 3rd Try Catch block -----
//Execute SELECT query from DB
String query = "UPDATE dbo.User_Table set is_Active=1 where firstName = ?";
Statement st = con.createStatement();
ResultSet rst = st.executeQuery(query);
while(rst.next()){
// newUserID = rst.getInt("userID");
}
}catch (Exception e){
e.printStackTrace();
}
} else {
Toast.makeText(verification_screen.this, "FAIL", Toast.LENGTH_SHORT).show();
pinEntry.setText(null);
}
}
});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment