firebase login and signup help in kivy Python code - firebase-authentication

i have it so when entering the info into the signup input boxes and hitting the submit button.. it saves into the realtimedb in firebase auth.. the problem comes when i want to authenticate a user and then if the user isn't in the db i need to display a message
basically my code is...
loginsignup.py
from kivy.core.text import LabelBase
from kivy.core.window import Window
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen,ScreenManager
from kivymd.app import MDApp
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
class MyFirebaseSignup:
def sign_up(self, username, email, password, login_message=None):
try:
user = auth.create_user_with_email_and_password(email, password)
data = {"email": email, "password": password, "idToken": True}
info = auth.get_account_info(user["idToken"])
auth.send_email_verification(user["idToken"])
password = data.get("password")
print("Successfully created account")
#Go to login.kv page
except:
print("Invalid")
#Display Error message from firebase id: signup_message (signup.kv)
pass
class MyFirebaseLogin():
def Login(self, email, password):
try:
login = auth.sign_in_with_email_and_password(email, password)
info = auth.get_account_info(login["idToken"])
print("The data of text field is : ",self.root.ids.data.login)
print("Successfully Logged in")
#Go to profile.kv page
except:
print("Invalid")
#Display Error message from firebase id: login_message (login.kv)
pass
.....
def build(self):
screen_manager = ScreenManager()
screen_manager.add_widget(Builder.load_file("main.kv"))
screen_manager.add_widget(Builder.load_file("signup.kv"))
screen_manager.add_widget(Builder.load_file("login.kv"))
screen_manager.add_widget(Builder.load_file("forgotpassword.kv"))
screen_manager.add_widget(Builder.load_file("profile.kv"))
self.my_firebasesignup = MyFirebaseSignup()
self.my_firebaselogin = MyFirebaseLogin()
#self.firebaseForgotPassword = MyFirebaseForgotPassword()
return screen_manager
if __name__ == "__main__":
LoginSignup().run()
signup.kv
<SignupScreen>:
MDScreen:
name: "signup"
id: signup
MDFloatLayout:
text: "Create a new account"
MDLabel:
id: signup_message
color: (1,0,0,1)
MDFloatLayout:
TextInput:
id: login_username
hint_text: "Username"
multiline: False
MDFloatLayout:
TextInput:
id: login_email
hint_text: "Email"
multiline: False
MDFloatLayout:
TextInput:
id: login_password
hint_text: "Password"
multiline: False
password: True
Button:
text: "SIGNUP"
on_release:
print("Sign up", login_email.text, login_password.text)
app.my_firebasesignup.sign_up(login_username.text,login_email.text,login_password.text)
MDLabel:
text: "Already have an account?"
MDTextButton:
text: "Sign in"
on_release:
root.manager.transition.direction = "left"
root.manager.current = "login"
login.kv
<LoginScreen>:
MDScreen:
name: "login"
id: login
MDFloatLayout:
MDLabel:
text: "Sign in to continue"
MDLabel:
id: login_message
color: (1,0,0,1)
TextInput:
id: login_email
hint_text: "Email"
multiline: False
MDFloatLayout:
TextInput:
id: login_password
hint_text: "Password"
multiline: False
password: True
Button:
text: "LOGIN"
on_release:
print("Sign in", login_email.text, login_password.text)
app.my_firebaselogin.Login(login_email.text,login_password.text)
MDTextButton:
text: "Forgot Password?"
on_release:
root.manager.transition.direction = "left"
#root.manager.current = "forgotpassword"
MDLabel:
text: "Don't have an account?"
MDTextButton:
text: "Sign up"
on_release:
root.manager.transition.direction = "left"
root.manager.current = "signup"
i cant find in any of the tutorials online how to display the errors using a label or if successful to move forward to a new page
Basically how do i:
Once signed up successfully, then go to login.kv page ... if my other buttons on other screens to go on release, root.manager.current = "login"
If there is an error in the Signup details, display those details in the signup_message on the signup.kv page?
I took out the formatting, etc... and im sure it is so simple.. but i cant figure it out
once i know how to do it once... il be able to do it on the others, etc

Related

Masking credit-card input field in Cybersource Flex Microform

In my project, I'm using Cybersource Flex Microform for Credit Card validations, but unable to mask the entered number on blur or key-up.
I am using the 0.4.0 version of the Flex Microform API and in the options object, I'm giving inputType: "password".
window.FLEX.microform(
{
keyId: kid,
keystore: keystore,
container: '#cardNumber-container',
label: '#cardNumber-label',
styles: {
input: {
'font-size': '16px'
}
},
encryptionType: 'rsaoaep256',
inputType: 'password'
},
function(setupError, microformInstance) {
// credit card on blur event functionality
}
)
Still in the field, the input type is coming as the default "tel", but not as "password".

Liferay Login Hook, error pop up

I need to show the errors in login hook of liferay in popup, but the sentence is only a line of code, so I don't know how implement the popup.
the key line is the next:
<liferay-ui:error exception="<%= NoSuchUserException.class %>" message="This message is editable" />
This error is to showed in a label but I didn't need this.
like this example::
http://www.jose-aguilar.com/blog/wp-content/uploads/2012/07/bootstrap-modal.png
In case you need to show errors in dialog box,I suppose you are using
SessionErrors.add(actionRequest, "error");
to send error from action phase.You can check SeesionErrors for 'error' attribute and display your message in dialog box:
<% if(!SessionErrors.isEmpty(renderRequest))
{
String error=LanguageUtil.get(pageContext, "error");
%>
<aui:script>
YUI().ready(function(A) {
YUI().use('aui-base','liferay-util-window', function(A) {
Liferay.Util.Window.getWindow({
title : 'Error',
dialog: {
bodyContent: '<%=error%>',
destroyOnHide: true,
cache: false,
modal: true,
height: 300,
width: 300
}
})
});
});
</aui:script>
<%} %>
Have look at the Alloy Documentation
http://alloyui.com/examples/tooltip/
As Shivam suggested, you can use a scriplet to get the message.

ActiveAdmin menu ordering for Admin Comments model

How can I change the order for the ActiveAdmin Comments model?
With my own models I use
menu priority: NUMBER
in the Admin class. But what about its own Comments class?
I had a similar problem with ActiveAdmin 1.0beta and wanted to post my solution for posterity.
In initializers/active_admin.rb if you add the "Comments" as a label and disable them in the menu you can move the comments to a dropdown or to the end of the main menu list.
config.show_comments_in_menu = false
# if active_admin >= 1.0, use `config.comments_menu = false`
#....
config.namespace :admin do |admin|
admin.build_menu do |menu|
menu.add label: 'Dashboard', priority: 0
menu.add label: 'Revenue', priority: 3
menu.add label: 'Costs', priority: 4
menu.add label: 'Categories', priority: 5
menu.add label: 'Users & Comments', priority: 6
menu.add label: 'Comments', parent: 'Users & Comments', url: "/admin/comments"
end
end
Nowadays, you can set the Comments menu priority in config/active_admin.rb like so:
config.comments_menu = { priority: 1 }
The workaround I've found was using negative numbers for menus that I want to be sure are shown before the Comments model.
Answer similar to accepted response, however, for those that want to maintain other AA menu defaults.
config.show_comments_in_menu = false
config.namespace :admin do |admin|
admin.build_menu :default do |menu|
menu.add label: 'Comments', parent: 'Misc', url: "/admin/comments"
end
end

How to submit a SmartClient DynamicForm programmatically?

I am trying to create a hidden form with some data, which needs to be submitted to a jsp page (which gets open in a new window), but all this would happen programatically, without user pressing submit button.
My Sample code
var fsquery = "abcd";
var emailId = "as#gmail.com";
var portalPsswd = "password";
var projectId = "123";
var kbUrl = "some url which will consume form post parameters";
var pv="1.2",pn="ADA";
this.kbform=isc.DynamicForm.create({
width: 300,
fields: [
{type: "hiddenitem", name: "EMAIL_ID", defaultValue:emailId },
{type: "hiddenitem", name: "PORTAL_PASSWORD", defaultValue:portalPsswd},
{type: "hiddenitem", name: "PROJECT_ID", defaultValue:projectId},
{type: "hiddenitem", name: "FSQUERY", defaultValue:fsquery},
{type: "hiddenitem", name: "PRODUCT_VERSION", defaultValue:pv},
{type: "hiddenitem", name: "PRODUCT_NAME", defaultValue:pn},
{type: "hiddenitem", name: "ORIGIN", defaultValue:"Administrator"},
{type: "submit", name: "submit", defaultValue: "submit"}
],
action: kbUrl,
target: "_blank",
method: "POST",
canSubmit: true
});
this.kbform.submit();
the last statement does not submit the form automatically, but if I click the submit button provided, it works perfectly as needed.
Please provide me a solution which will help me simulate "submit" type button functionality to submit the form.
You can try this sample code here under "text.js" tab
I'm not sure about this, but have you tried triggering the submit on a window.onload event? I don't think the form is available until the document is fully loaded. I'm sorry I don't have any examples.

dojo DataGrid is not getting next page when scrolling

Here is my code:
<script>
require(["dojox/grid/DataGrid", "dojo/store/Memory","dojo/data/ObjectStore", "dojo/store/JsonRest", "dojo/_base/xhr", "dojo/domReady!"],
function(DataGrid, Memory, ObjectStore, JsonRest, xhr){
var gridSimple,
store,
dataStore;
function createGrid(){
gridSimple = new DataGrid({
store: dataStore,
structure: [
{ name: "Name", field: "name", width: "84px" },
{ name: "Last name", field: "lastName", width: "84px" },
{ name: "e-mail", field: "email", width: "120px" }
],
rowsPerPage: 20,
autoHeight:15,
selectionMode: "single"
}, "grid");
gridSimple.startup();
}
function init(){
store = new JsonRest({target: "/users/"});
dataStore = ObjectStore({objectStore: store});
createGrid();
}
init();
});
</script>
<div id="grid">
</div>
I'm getting the first page (The Range header is being sent), but when scrolling down nothing happens, dojo is not sending the next request. Not sure what I'm doing wrong.
I'm on firefox 14.0.1, btw the scroll is really really slow using the mouse wheel. I also tried in chrome, not getting next page, but at least the mouse wheel works just fine.
Dojo version: 1.7.2
The problem was I had to add the next header to my response:
response.addHeader("Content-Range", "items " + from + "-" + to + "/" + total);
I did not know this. It is what they call the "REST Paging standard". http://dojotoolkit.org/reference-guide/1.7/dojo/store/JsonRest.html#id7
On the other hand, firefox is scrolling painfully slow. Not happening in chrome.
Here is the bug report:
http://bugs.dojotoolkit.org/ticket/15487
So, in firefox preferences>Advanced> uncheck "Use smooth scrolling".