Example #1
0
d = {}
arguments = cgi.FieldStorage()
newuser = arguments.getvalue('Newuser')
username = arguments.getvalue('username')
if newuser == None:
    d['success'] = 0
    d['message'] = 'Field is empty'
    print json.dumps(d)
else:
    if len(newuser) <= 4 or len(newuser) >= 20:
         d['success'] = 0
         d['message'] = 'Username has an incorrect length(must be more than 4 characters and less than 20)'
         print json.dumps(d)
    else:
        if LogApi.check_user(newuser):
            d['success'] = 0
            d['message'] = 'Username already exists'
            print json.dumps(d)
        else:
            LogApi.Change_User(username, newuser)
            username.lower()
            newuser = newuser.lower()
            currentbig = '/home1/skyrealm/public_html/img/%sorig.jpg' % username
            currentpath = '/home1/skyrealm/public_html/img/%s.jpg' % username 
            newpath = '/home1/skyrealm/public_html/img/%sorig.jpg' % newuser
            newpathandname = '/home1/skyrealm/public_html/img/%s.jpg' % newuser
            os.rename(currentbig,newpath)
            os.rename(currectpath,newpathandname)
            d['success'] = 1
            d['message'] = 'Username Changed'
Example #2
0
print "Content-type: text/html\r\n\r\n"

d = {}


arguments = cgi.FieldStorage()
username = arguments.getvalue("username")
password = arguments.getvalue("password")
hashed_password = None
salt = None
if username == None or password == None:
    d["success"] = 0
    d["message"] = "Login or password is empty"
    print json.dumps(d)
else:
    if LogApi.check_user(username):
        hashed_password = LogApi.get_password(username)
        salt = LogApi.get_Salt(username)
        password = LogApi.hash_password(password, salt)
        if hashed_password == password:
            d["success"] = 1
            d["message"] = "Logged in successfully"
            print json.dumps(d)
        else:
            d["success"] = 0
            d["message"] = "Incorrect username or password"
            print json.dumps(d)
    else:
        d["success"] = 0
        d["message"] = "Incorrect username"
        print json.dumps(d)
Example #3
0
if username == None or password == None or email == None:
    d['success'] = 0
    d['message'] = 'Field is empty'
    print json.dumps(d)
else:
    if len(username) <= 4 or len(username) >= 20:
        d['success'] = 0
        d['message'] = 'Username or password has an incorrect length(must be more than 4 characters and less than 20)'
        print json.dumps(d)
    else:
        if len(password) >= 20 or len(password) <= 4:
            d['success'] = 0
            d['message'] = 'Username or password has an incorrect length(must be more than 4 characters and less than 20)'
            print json.dumps(d)
        else:
            if LogApi.check_user(username):
                d['success'] = 0
                d['message'] = 'Username already exists'
                print json.dumps(d)
            else:
                if LogApi.validateEmail(email) == 1:
                    if LogApi.check_email(email):
                        d['success'] = 0
                        d['message'] = 'Email is already registered to another account'
                        print json.dumps(d)
                    else:
                    #Add password restrictions and add profanity filter to username.
                        password, salt = LogApi.hash_password(password)
                        LogApi.CreateUser(username, password, salt, email)
                        shutil.copyfile(currentpath, newpathandname)                 
                        d['success'] = 1
Example #4
0
#! /usr/bin/python
import LogApi
import cgi
import json

print "Content-type: text/html\r\n\r\n"

d = {}
arguments = cgi.FieldStorage()
ueforgot= arguments.getvalue('useremail')
subject = 'Password Reset'
if ueforgot == None:
    d['success'] = 0
    d['message'] = 'Field is empty'
    print json.dumps(d)
else:
    if LogApi.check_ue(ueforgot): 
        emailadd = LogApi.get_email(ueforgot)
        newpass = LogApi.pass_generator()
        message = 'Your new temporary password is:%s \n To reset: \n Go to profile and change password' % newpass
        newpass, salt = LogApi.hash_password(newpass)
        LogApi.New_Pass(ueforgot, newpass, salt)
        LogApi.send_email(emailadd, subject, message)
        d['success'] = 1
        d['message'] = 'Your new password and instuctions have been sent to your e-mail!'
        print json.dumps(d)
    else:
        d['success'] = 0
        d['message'] = 'Username or email not found in our system'
        print json.dumps(d)