Example #1
0
def user_login():
    up = request.forms.upass1.strip().encode('utf-8')
    out = reg.mk_reg(request.forms)
    if up.startswith(':') and up.endswith(':'):
        ud = udata(up)
    else:
        if not out.startswith(':'):
            return out
        ud = udata(out)
    response.set_cookie('kvitok',
                        ud.kvitok.encode('utf-8'),
                        path='/',
                        max_age=7776000)
    return template('reg/user.html', u=ud, ea=request.forms.ea, admikey=ak())
Example #2
0
def create_message_point():
    ud = udata(request.forms.pauth.encode('utf-8'))
    dta = b64d(request.forms.tmsg.encode('utf-8')).decode('utf-8').splitlines()
    repto, tags = '', ''
    if dta[4].startswith('@repto:'):
        repto = dta[4][7:]
        if len(repto) != 20:
            return 'wrong repto!'
        txt = '\n'.join(dta[5:])
    elif dta[4].startswith('@tags:'):
        tags = dta[4][6:]
        txt = '\n'.join(dta[5:])
    else:
        txt = '\n'.join(dta[4:])
    mo = mydict(ea=dta[0],
                txt=txt,
                repto=repto,
                tags=tags,
                to=dta[1],
                title=dta[2] or '***')
    if repto:
        mo.topicid = api.get_msg(repto).topicid
    if ud.check() and ud.uname:
        nmsg = api.create_msg(mo, ud)
    return 'msg ok:%s' % nmsg
Example #3
0
def create_message():
    ud = udata(request.forms.kvitok.encode('utf-8'))
    if not ud.check() or not ud.uname:
        return u'доступ не подтверждён, сочувствуем'
    nmsg = api.create_msg(request.forms,ud)
    if request.forms.typ == 'echo':
        redirect ('/echo/%s#go_%s' % (request.forms.ea, nmsg))
    else:
        redirect ('/%s/%s#go_%s' % (dict(forum='topic',blog='msg').get(request.forms.typ),request.forms.topicid or nmsg, nmsg))
Example #4
0
def auth_user_bykey():
    ud = udata(request.forms.kvitok.encode('utf-8'))
    if request.forms.kvitok:
        if ud.check():
            response.set_cookie('kvitok', ud.kvitok, path='/', max_age=7776000)
            return template('''<html><head>
                    <meta http-equiv="refresh" content="3; {{redir}}" />
                    </head><body><p>Пользователь: <b>{{ud.uname}}</b></p>
                    <p>Адрес: <b>{{ud.uaddr}}</b></p>
                    <p>Авторизация принята. Осуществляется переход по адресу: <a href="{{redir}}">{{redir}}</a></p></body></html>''', 
                    ud=ud, redir=request.forms.redir.encode('utf-8').decode('base64') or '/')
        else:
            return template('{{ud.uname}}<br>{{ud.uaddr}}<br><br>Ключ не принят, сожалеем. Обратитесь к производителю.',ud=ud)
    else:
        response.set_cookie('kvitok', '', path='/', max_age=7776000)
        return template('<html><head><meta http-equiv="refresh" content="3; {{redir}}" /></head><body><p>Авторизация cнята. Осуществляется переход по адресу: <a href="{{redir}}">{{redir}}</a></p></body></html>', ud=ud, redir=request.forms.redir.encode('utf-8').decode('base64') or '/')
Example #5
0
def u():
    return udata(request.cookies.kvitok.encode('utf-8'))
Example #6
0
def key_test_api():
    if udata(request.forms.kvitok).check():
        return 'ok'
Example #7
0
def user_info():
    ud = u()
    if request.query.logout:
        response.set_cookie('kvitok', '', path='/', max_age=7776000)
        ud = udata('')
    return template('reg/user.html', u=ud, ea=request.query.ea, admikey=ak())
Example #8
0
def key_test_api():
    if udata(request.forms.kvitok.encode('utf-8')).check():
        return 'ok'