Esempio n. 1
0
    def signingUp(self, Dialog):


        uName = self.uNameLine.text()
        uPassword = self.uPasswordLine.text()
        if client.known_user(uName, False):
            self.infLabel.setText("Cannot use this login!")
            return
        client.register(uName,uPassword)

        ip = self.IPline.text()
        data.username = uName
        data.password = uPassword

        client.IP = ip
        print("4")
        if len(data.username)!=0 and len(data.userid)!=0 and len(data.password)!=0 and len( client.IP)!=0 and functions.is_number(data.userid):
            print("start")
            try:
                data.userid = client.get_id(uName)
                data.balance = (client.get_balance(uName), "$")
                if self.size.currentText() == "Big":
                    data.scale = [1.14, 1.2, 4.5, 1.4]
                    data.scale_ = [2.1, 1.5, 4.3, 3]
                functions.putPersonalData()

                mainWindow.runGUI()
                #print("signUp")
            except:
                print("Error while starting app")
                self.clearWin(Dialog)
        else:
            self.infLabel.setText("Error. Try Again!")

        return
Esempio n. 2
0
    def register(self):
        try:
            box = QtWidgets.QMessageBox()
            nick_name = self.lineEdit.text()
            user_name = self.lineEdit_2.text()
            password = self.lineEdit_3.text()
            phone = self.lineEdit_4.text()
            email = self.lineEdit_5.text()
            if len(nick_name) > 7:
                box.warning(self, '提示', '昵称太长')
            elif len(nick_name) == 0:
                box.warning(self, '提示', '昵称为空')
            elif len(user_name) > 8:
                box.warning(self, '提示', '账号太长')
            elif len(user_name) == 0:
                box.warning(self, '提示', '请输入账号')
            elif not re.match("^[a-zA-Z0-9_]{0,8}$", user_name):
                box.warning(self, "提示", "账号输入格式有误!")
            elif len(password) > 12:
                box.warning(self, '提示', '密码太长')
            elif len(password) == 0:
                box.warning(self, '提示', '请输入密码')
            elif not re.match("^[a-zA-Z0-9_]{0,12}$", password):
                box.warning(self, "提示", "密码输入格式有误!")
            elif len(phone) > 11 or len(phone) < 11:
                box.warning(self, '警告', '手机号格式错误!')
            elif not re.match("^[0-9]{0,11}$", phone):
                box.warning(self, '警告', '手机号输入有误!')
            elif not re.search('@', email):
                box.warning(self, '提示', '邮箱格式有误!')
            else:
                reg = dict()
                password = client.passwd_md5(password)
                reg["nick_name"] = nick_name
                reg["user_name"] = user_name
                reg["password"] = password
                reg["phone"] = phone
                reg["email"] = email
                print(reg)
                b = client.register(reg)
                if b == 0:
                    box.information(self, "恭喜", "注册成功!")
                    self.close()
                elif b == 1:
                    box.warning(self, '警告', '该用户名已存在!')

                elif b == 2:
                    box.warning(self, '警告', '该账号已存在!')

                else:
                    box.warning(self, '警告', '该邮箱已存在!')
        except Exception as f:
            print(f)
Esempio n. 3
0
def action_signup():
    if request.method == 'POST':
        para = ("name", "password", "email", "phone")

        for item in para:
            if not request.form.has_key(item):
                return "0"
        print str(request.form)
        result = client.register(request.form['name'],
                                 request.form['password'],
                                 request.form['email'], request.form['phone'])
        if result == "-1\n":
            return "0"
        else:
            session['userid'] = result[:-1]
            return "1"
    return "0"
Esempio n. 4
0
def register():
    if request.method != "POST":
        current_user = session.get('username')
        if current_user:
            flash("danger 注册失败! 您已登录,请先登出后再进行注册")
            return redirect(url_for("main_page"))
        else:
            return render_template("register.html",
                                   user_id=None,
                                   username=None,
                                   privilege=None
                                   )

    else:
        element = ('username', 'password_1', 'email', 'phone')

        for item in element:
            if item not in request.form:
                flash("danger 注册失败! 未知注册错误A")
                return redirect(url_for('register'))

        current_user = client.register(request.form['username'],
                                       request.form['password_1'],
                                       request.form['email'],
                                       request.form['phone']
                                       )

        if current_user != -1:
            session['user_id'] = current_user
            session['username'] = request.form['username']
            session['privilege'] = client.get_privilege(current_user)
            flash("success 注册成功! 您的用户ID是{},请牢记此ID,本系统只能使用ID登录。请尽情使用吧~".format(current_user))
            return redirect(url_for("main_page"))
        else:
            flash("danger 注册失败! 未知注册错误B")
            return redirect(url_for('register'))
Esempio n. 5
0
def user_add():
    """添加用户"""
    client.register()
Esempio n. 6
0
import client
import sys
sys.path.insert(0, '/home/henchill/Documents/Workspace/encrypted_file_system/server')

from server import *
from encrypt import *

if __name__ == "__main__":
 
    resp1 = client.register('aakriti')
    resp2 = client.register('henchill')
    
    print 'create aakriti: ', resp1
    print 'create henchill: ', resp2
    
    
import client
import sys
sys.path.insert(0, '/home/henchill/Documents/Workspace/encrypted_file_system/server')

from server import *
from encrypt import *

if __name__ == "__main__":
 
    resp = client.register('bottom')
    resp = client.register('henchill')
    # print "register: ", resp
    
    

    client.signIn('henchill')
    resp = client.createFile("test.txt")
    # print "create file: ", resp

    resp = client.createDirectory("foo");
    print "create dir: ", resp

    resp = client.writeFile('test.txt');
    print "write file: ", resp

    resp = client.readFile('test.txt');
    print "read file: ", resp

    resp = client.setPerm('test.txt', 'r', ['bottom'])
    print "write acl: ", resp
import client
import sys
sys.path.insert(
    0, '/home/henchill/Documents/Workspace/encrypted_file_system/server')

from server import *
from encrypt import *

if __name__ == "__main__":

    resp = client.register('bottom')
    resp = client.register('henchill')
    # print "register: ", resp

    client.signIn('henchill')
    resp = client.createFile("test.txt")
    # print "create file: ", resp

    resp = client.createDirectory("foo")
    print "create dir: ", resp

    resp = client.writeFile('test.txt')
    print "write file: ", resp

    resp = client.readFile('test.txt')
    print "read file: ", resp

    resp = client.setPerm('test.txt', 'r', ['bottom'])
    print "write acl: ", resp

    resp = client.listDir('foo')
Esempio n. 9
0
import client
import sys
import getpass

if __name__ == '__main__':
    sys.stdout.write('Username: ')
    user = raw_input()
    passwd = getpass.getpass()
    client = client.KerberosClient(user, passwd)
    client.register()