Skip to content

Commit 5baefbd

Browse files
committed
fix oracle reset password issue
1 parent b9c0608 commit 5baefbd

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

easyweb/static/des_components/des-login/des-login-reset.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
</paper-card>
5959
</div>
6060
<paper-toast class="toast-position" id="toastSignUp" text="Form Submitted!" duration="2000"> </paper-toast>
61+
<paper-toast class="toast-position" id="toastSignUpError" text="ERROR: Check your form" duration="2000"> </paper-toast>
6162
</template>
6263

6364
<script>
@@ -121,17 +122,19 @@
121122
'url': this.randomurl
122123
};
123124
form2.generateRequest();
124-
document.getElementById("toastSignUp").show();
125+
//document.getElementById("toastSignUp").show();
125126
},
126127
afterNewPasswordForm: function(e){
127128
var _self = this;
128129
document.getElementById('LoginSpinnerReset').active = false;
129130
_self.data = e.detail.response;
130131
console.log(_self.data.msg);
131132
if (_self.data.errno == '0') {
133+
document.getElementById("toastSignUp").show();
132134
window.location.href = "/easyweb/logout/";
133135
}
134136
else {
137+
document.getElementById("toastSignUpError").show();
135138
var button = document.getElementById('NewPassButton');
136139
button.disabled = false;
137140
this.error = _self.data.msg;

easyweb/static/elements/elements-built.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -47608,6 +47608,7 @@ <h2>Terms of Service</h2>
4760847608
</paper-card>
4760947609
</div>
4761047610
<paper-toast class="toast-position" id="toastSignUp" text="Form Submitted!" duration="2000"> </paper-toast>
47611+
<paper-toast class="toast-position" id="toastSignUpError" text="ERROR: Check your form" duration="2000"> </paper-toast>
4761147612
</template>
4761247613

4761347614
<script>
@@ -47671,17 +47672,19 @@ <h2>Terms of Service</h2>
4767147672
'url': this.randomurl
4767247673
};
4767347674
form2.generateRequest();
47674-
document.getElementById("toastSignUp").show();
47675+
//document.getElementById("toastSignUp").show();
4767547676
},
4767647677
afterNewPasswordForm: function(e){
4767747678
var _self = this;
4767847679
document.getElementById('LoginSpinnerReset').active = false;
4767947680
_self.data = e.detail.response;
4768047681
console.log(_self.data.msg);
4768147682
if (_self.data.errno == '0') {
47683+
document.getElementById("toastSignUp").show();
4768247684
window.location.href = "/easyweb/logout/";
4768347685
}
4768447686
else {
47687+
document.getElementById("toastSignUpError").show();
4768547688
var button = document.getElementById('NewPassButton');
4768647689
button.disabled = false;
4768747690
this.error = _self.data.msg;

login_public.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def post(self):
8585
print('Reset Password')
8686
app_log.info('Reset Password')
8787
check, url, checkuser = db_utils.create_reset_url(email)
88+
print(url)
8889
if check:
8990
email_utils.send_reset(email, checkuser, url)
9091
app_log.info('{},{},{}'.format(email, url, checkuser))
@@ -103,9 +104,12 @@ def put(self):
103104
if username == username2:
104105
print('valid', valid)
105106
if valid:
106-
db_utils.update_password(username, password)
107-
db_utils.unlock_user(username)
108-
self.write(json.dumps({'msg': 'Password updated', 'errno': '0'}))
107+
check, msg = db_utils.update_password(username, password)
108+
if check:
109+
db_utils.unlock_user(username)
110+
self.write(json.dumps({'msg': 'Password updated', 'errno': '0'}))
111+
else:
112+
self.write(json.dumps({'msg': msg + '. Try again', 'errno': '1'}))
109113
else:
110114
msg = 'Password minimum length is 6.'
111115
self.write(json.dumps({'msg': msg, 'errno': '1'}))

oracle/db_utils.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,18 @@ def delete_url(url):
134134
def update_password(username, password):
135135
con = ea.connect('desdr')
136136
qlock = "ALTER USER {0} IDENTIFIED BY {1}".format(username, password)
137-
con.query_and_print(qlock, suc_arg='Password Changed')
138-
delete_old = "DELETE FROM DES_ADMIN.RESET_URL WHERE USERNAME = '{}'".format(username)
139-
con.query_and_print(delete_old, suc_arg='Delete used Url')
137+
valid = False
138+
try:
139+
con.cur.execute(qlock)
140+
valid = True
141+
msg = 'ok'
142+
except Exception as e:
143+
msg = str(e)
144+
if valid:
145+
delete_old = "DELETE FROM DES_ADMIN.RESET_URL WHERE USERNAME = '{}'".format(username)
146+
con.query_and_print(delete_old, suc_arg='Delete used Url')
140147
con.close()
141-
return True
148+
return valid, msg
142149

143150

144151
def update_info(username, firstname, lastname, email, user_manager='', pass_manager=''):

0 commit comments

Comments
 (0)