File size: 1,518 Bytes
097a83e
c791e6c
 
097a83e
c791e6c
aa127d8
18c7174
c791e6c
097a83e
c791e6c
 
 
 
 
 
 
 
 
 
 
 
 
097a83e
c791e6c
 
 
097a83e
c791e6c
097a83e
c791e6c
097a83e
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import gradio as gr
from simple_salesforce import Salesforce
import os

# Salesforce login credentials (replace with your credentials or use environment variables for security)
sf = Salesforce(username='sairam13@gmail.com',
                password='Subbu@13',
                security_token=' 70kWpq95LK10gbSzirLeBkLo6')

# Function to store login info in Salesforce
def store_login_in_salesforce(username, password):
    try:
        # Create a new Login_Record__c in Salesforce with the login details
        sf.	login_credential__c.create({
            'Username__c': username,
            'Password__c': password  # You might want to store the password securely in Salesforce
        })
        return True
    except Exception as e:
        return False

# Function to handle login logic (stores login info in Salesforce without validation)
def login(username, password):
    # Store login information in Salesforce
    if store_login_in_salesforce(username, password):
        return "Login info stored in Salesforce! Welcome, " + username + "."
    else:
        return "There was an issue storing your info in Salesforce."

# Gradio Interface
with gr.Blocks() as demo:
    gr.Markdown("# Login Page")
    
    username = gr.Textbox(label="Username")
    password = gr.Textbox(label="Password", type="password")
    
    login_button = gr.Button("Login")
    output = gr.Textbox(label="Message", interactive=False)
    
    login_button.click(login, inputs=[username, password], outputs=output)

demo.launch()