def post(self):
        name = self.get_argument('name', '')
        mail = self.get_argument('mail', '')
        errtip = Errtip()
        if mail:
            mail = mail.lower()
        if not mail:
            errtip.mail = '请输入邮箱'
        elif not EMAIL_VALID.match(mail):
            errtip.mail = '邮箱格式有误'

        if not name:
            errtip.name = '请输入姓名'


        if not errtip:
            user_id = user_id_by_mail(mail)
            if not user_id:
                user_id = user_new(mail, name=name)
                #session = user_session(user_id)
                #self.set_cookie('S', session)
                self.set_cookie('E', mail)

                phone = self.get_argument('phone', '')
                namecard_new(user_id,phone=phone)

            return self.redirect('/auth/reged/%s'%user_id)

        self.render(
            mail=mail,
            name=name,
            errtip=errtip
        )
Beispiel #2
0
    def post(self):
        errtip = Errtip()
        user_id = self.current_user_id
        user = self.current_user

        password = self.get_argument('password', None)
        mail = self.get_argument('mail', None)
        if not mail:
            errtip.mail = '请输入邮箱'
        elif not EMAIL_VALID.match(mail):
            errtip.mail = '邮件格式不正确'

        if not password:
            errtip.password = '******'
        elif not user_password_verify(user_id, password):
            errtip.password = '******'
            password = ''

        if not errtip:
            from model.user_mail import user_mail_new, user_mail_by_state, MAIL_VERIFIED, user_mail_active_by_user
            if mail in user_mail_by_state(user_id, MAIL_VERIFIED):
                user_mail_active_by_user(user, mail)
                return self.redirect('/i/account/mail/success')

            if user_mail_new(user_id, mail):
                verify_mail_new(user_id, self.current_user.name, mail,
                                CID_VERIFY_LOGIN_MAIL)
            else:
                errtip.mail = '该邮箱已经注册'

        self.render(mail=mail, errtip=errtip, password=password)
Beispiel #3
0
    def post(self):
        name = self.get_argument('name', '')
        mail = self.get_argument('mail', '')
        errtip = Errtip()
        if mail:
            mail = mail.lower()
        if not mail:
            errtip.mail = '请输入邮箱'
        elif not EMAIL_VALID.match(mail):
            errtip.mail = '邮箱格式有误'

        if not name:
            errtip.name = '请输入姓名'

        if not errtip:
            user_id = user_id_by_mail(mail)
            if not user_id:
                user_id = user_new(mail, name=name)
                #session = user_session(user_id)
                #self.set_cookie('S', session)
                self.set_cookie('E', mail)

                phone = self.get_argument('phone', '')
                namecard_new(user_id, phone=phone)

            return self.redirect('/auth/reged/%s' % user_id)

        self.render(mail=mail, name=name, errtip=errtip)
Beispiel #4
0
    def post(self):
        errtip = Errtip()
        user_id = self.current_user_id
        user = self.current_user

        password = self.get_argument('password', None)
        mail = self.get_argument('mail', None)
        if not mail:
            errtip.mail = '请输入邮箱'
        elif not EMAIL_VALID.match(mail):
            errtip.mail = '邮件格式不正确'

        if not password:
            errtip.password = '******'
        elif not user_password_verify(user_id, password):
            errtip.password = '******'
            password = ''

        if not errtip:
            from model.user_mail import user_mail_new, user_mail_by_state, MAIL_VERIFIED, user_mail_active_by_user
            if mail in user_mail_by_state(user_id, MAIL_VERIFIED):
                user_mail_active_by_user(user, mail)
                return self.redirect('/i/account/mail/success')

            if user_mail_new(user_id, mail):
                verify_mail_new(
                    user_id, self.current_user.name, mail, CID_VERIFY_LOGIN_MAIL
                )
            else:
                errtip.mail = '该邮箱已经注册'

        self.render(mail=mail, errtip=errtip, password=password)
Beispiel #5
0
def _invite_friend(self, mail_name_list):
    for mail, name in mail_name_list:
        mail = mail.strip().lower()
        name = name.strip()
        if EMAIL_VALID.match(mail):
            user_id = user_id_by_mail(mail)
            if not user_id:
                user = user_new_by_mail(mail, name=name)
                user_id = user.id

            zsite_review_invite(self.zsite, user_id, self.current_user)
Beispiel #6
0
def _invite_friend(self, mail_name_list):
    for mail, name in mail_name_list:
        mail = mail.strip().lower()
        name = name.strip()
        if EMAIL_VALID.match(mail):
            user_id = user_id_by_mail(mail)
            if not user_id:
                user = user_new_by_mail(mail, name=name)
                user_id = user.id

            zsite_review_invite(self.zsite, user_id, self.current_user)
Beispiel #7
0
 def post(self):
     hr_mail = self.get_argument('hr_mail', None)
     errtip = Errtip()
     if not EMAIL_VALID.match(hr_mail):
         errtip.hr_mail = '请输入正确的邮箱'
     if not errtip:
         job_mail_new_with_verify_mail(self.zsite, self.current_user_id, hr_mail)
         self.get()
     else:
         self.render(
             errtip=errtip,
             hr_mail=hr_mail,
         )
Beispiel #8
0
 def post(self):
     hr_mail = self.get_argument('hr_mail', None)
     errtip = Errtip()
     if not EMAIL_VALID.match(hr_mail):
         errtip.hr_mail = '请输入正确的邮箱'
     if not errtip:
         job_mail_new_with_verify_mail(self.zsite, self.current_user_id,
                                       hr_mail)
         self.get()
     else:
         self.render(
             errtip=errtip,
             hr_mail=hr_mail,
         )
Beispiel #9
0
 def get(self, mail):
     if mail.isdigit():
         user_id = mail
         user = Zsite.mc_get(user_id)
         if user:
             mail = mail_by_user_id(user_id)
             link = mail2link(mail)
             if user:
                 return self.render(mail=mail, link=link)
     elif EMAIL_VALID.match(mail):
         user_id = user_id_by_mail(mail)
         if user_id:
             user = Zsite.mc_get(user_id)
             verify_mail_new(user_id, user.name, mail, self.cid)
             return self.redirect('/auth/password/reset/%s' % user_id)
     self.redirect('/login')
Beispiel #10
0
 def get(self, mail):
     if mail.isdigit():
         user_id = mail
         user = Zsite.mc_get(user_id)
         if user:
             mail = mail_by_user_id(user_id)
             link = mail2link(mail)
             if user:
                 return self.render(mail=mail, link=link)
     elif EMAIL_VALID.match(mail):
         user_id = user_id_by_mail(mail)
         if user_id:
             user = Zsite.mc_get(user_id)
             verify_mail_new(user_id, user.name, mail, self.cid)
             return self.redirect('/auth/password/reset/%s'%user_id)
     self.redirect('/login')
Beispiel #11
0
    def post(self):
        current_user_id = self.current_user_id
        hr_mail = self.get_argument('hr_mail', '').strip().lower()
        zsite_id = self.zsite_id
        zsite = self.zsite

        errtip = Errtip()
        if hr_mail:
            if not EMAIL_VALID.match(hr_mail):
                errtip.mail = '邮件格式错误'
        else:
            errtip.mail = '请输入邮箱'

        if errtip:
            return self.render(errtip=errtip, current_user_id=current_user_id)
        else:
            job_mail_new_with_verify_mail(zsite, current_user_id, hr_mail)
            return self.redirect('/job/mail/verify')
Beispiel #12
0
    def post(self):
        current_user_id = self.current_user_id
        hr_mail = self.get_argument('hr_mail', '').strip().lower()
        zsite_id = self.zsite_id
        zsite = self.zsite

        errtip = Errtip()
        if hr_mail:
            if not EMAIL_VALID.match(hr_mail):
                errtip.mail = '邮件格式错误'
        else:
            errtip.mail = '请输入邮箱'

        if errtip:
            return self.render(errtip=errtip, current_user_id=current_user_id)
        else:
            job_mail_new_with_verify_mail(zsite, current_user_id, hr_mail)
            return self.redirect('/job/mail/verify')
    def post(self, mail=None):
        mail = self.get_argument('mail', '')
        sex = self.get_argument('sex', '0')
        errtip = Errtip()
        if sex:
            sex = int(sex)
            if sex not in (1, 2):
                sex = 0

        if mail:
            mail = mail.lower()
        if not mail:
            errtip.mail = '请输入邮箱'
        elif not EMAIL_VALID.match(mail):
            errtip.mail = '邮箱格式有误'

        #if not password:
        #    errtip.password = '******'

        if not errtip:
            user_id = user_id_by_mail(mail)
            if user_id:
                #if user_password_verify(user_id, password):
                #    return self._login(user_id, mail)
                #else:
                errtip.mail = '邮箱已注册。忘记密码了?<a href="/auth/password/reset/%s">点此找回</a>' % escape(mail)

        if not sex:
            errtip.sex = '请选择性别'

        if not errtip:
            user_id = user_new(mail, sex=sex)
            return self.redirect('/auth/verify/send/%s'%user_id)

        self.render(
            sex=sex,
            mail=mail,
            errtip=errtip
        )
def _mail_password_post(self):
    mail = self.get_argument('mail', None)
    password = self.get_argument('password', None)
    errtip = Errtip()

    if mail:
        mail = mail.lower()
    if not mail:
        errtip.mail = '请输入邮箱'
    elif not EMAIL_VALID.match(mail):
        errtip.mail = '邮箱格式有误'

    if not password:
        errtip.password = '******'

    user_id = 0
    if not errtip:
        user_id = user_id_by_mail(mail)
        if user_id:
            if not user_password_verify(user_id, password):
                errtip.password = '******' % escape(mail)

    return user_id , mail, password, errtip
Beispiel #15
0
def _mail_password_post(self):
    mail = self.get_argument('mail', None)
    password = self.get_argument('password', None)
    errtip = Errtip()

    if mail:
        mail = mail.lower()
    if not mail:
        errtip.mail = '请输入邮箱'
    elif not EMAIL_VALID.match(mail):
        errtip.mail = '邮箱格式有误'

    if not password:
        errtip.password = '******'

    user_id = 0
    if not errtip:
        user_id = user_id_by_mail(mail)
        if user_id:
            if not user_password_verify(user_id, password):
                errtip.password = '******' % escape(
                    mail)

    return user_id, mail, password, errtip
Beispiel #16
0
    def post(self, mail=None):
        mail = self.get_argument('mail', '')
        sex = self.get_argument('sex', '0')
        errtip = Errtip()
        if sex:
            sex = int(sex)
            if sex not in (1, 2):
                sex = 0

        if mail:
            mail = mail.lower()
        if not mail:
            errtip.mail = '请输入邮箱'
        elif not EMAIL_VALID.match(mail):
            errtip.mail = '邮箱格式有误'

        #if not password:
        #    errtip.password = '******'

        if not errtip:
            user_id = user_id_by_mail(mail)
            if user_id:
                #if user_password_verify(user_id, password):
                #    return self._login(user_id, mail)
                #else:
                errtip.mail = '邮箱已注册。忘记密码了?<a href="/auth/password/reset/%s">点此找回</a>' % escape(
                    mail)

        if not sex:
            errtip.sex = '请选择性别'

        if not errtip:
            user_id = user_new(mail, sex=sex)
            return self.redirect('/auth/verify/send/%s' % user_id)

        self.render(sex=sex, mail=mail, errtip=errtip)
Beispiel #17
0
    def post(self):
        current_user = self.current_user
        zsite = self.zsite
        request = self.request
        errtip = Errtip()
        zsite_id = self.zsite_id

        url, title = self._arguments()
        amount = self.get_argument('amount', 0)
        alipay_account = self.get_argument('alipay_account', '')

        if not amount:
            errtip.amount = '请输入金额'
        else:
            try:
                amount = float(amount)
            except ValueError:
                errtip.amount = '%s 不是有效的金额'%amount
            else:
                if amount <= 0:
                    errtip.amount = '金额须大于零'
                elif amount >= 9999999:
                    errtip.amount = '金额超出上限'
                else:
                    amount_cent = amount * 100

        if not current_user:
            mail = self.get_argument('mail', '')
            if not mail:
                errtip.mail = '请输入联系邮箱'
            elif not EMAIL_VALID.match(mail):
                errtip.mail = '邮箱无效'
            else:
                user = user_by_mail(mail)
                self.set_cookie('E', mail.strip().lower())
                if not user:
                    user = user_new_by_mail(mail)
                elif user.state >= ZSITE_STATE_APPLY:
                    return self.redirect(
                              '/auth/login?next=%s'%request.uri
                           )
                current_user = user

        if current_user and not errtip:
            subject = '%s 向 %s 捐赠 %.2f 元' % (current_user.name, zsite.name, amount)
            current_user_id = current_user.id
            balance_cent = bank.get(current_user_id)

            def _pay_new(state):
                return pay_new(amount, current_user_id, zsite_id, CID_TRADE_PAY, state).id


            txt = self.get_argument('txt', None)
            secret = self.get_argument('secret', None)

            message = {}

            if title:
                message['title'] = title
            if url:
                message['url'] = url
            if txt:
                message['txt'] = txt
                if secret:
                    message['secret'] = secret




            if balance_cent >= amount_cent:
                o_id = _pay_new(TRADE_STATE_FINISH)
                if message:
                    trade_log.set(o_id, dumps(message))
                pay_notice(o_id)

                return self.redirect('%s/pay/result/%s'%(SITE_HTTP, o_id))
            elif balance_cent > 0:
                subject += '(余额支付 %.2f 元)' % (balance_cent/100.0)
                o_id = _pay_new(TRADE_STATE_NEW)
                amount_cent -= balance_cent
            else:
                o_id = _pay_new(TRADE_STATE_NEW)

            trade_log.set(o_id, dumps(message))

            return_url = '%s/money/alipay_sync' % SITE_HTTP
            notify_url = '%s/money/alipay_async' % RPC_HTTP

            alipay_url = alipay_payurl_with_tax(
                current_user_id,
                amount_cent/100.0,
                return_url,
                notify_url,
                subject,
                alipay_account,
                o_id
            )

            return self.redirect(alipay_url)

        self.render(
            url=url, title=title,
            amount=amount,
            errtip=errtip,
            alipay_account=alipay_account
        )
Beispiel #18
0
    def post(self):
        current_user = self.current_user
        zsite = self.zsite
        request = self.request
        errtip = Errtip()
        zsite_id = self.zsite_id

        url, title = self._arguments()
        amount = self.get_argument('amount', 0)
        alipay_account = self.get_argument('alipay_account', '')

        if not amount:
            errtip.amount = '请输入金额'
        else:
            try:
                amount = float(amount)
            except ValueError:
                errtip.amount = '%s 不是有效的金额' % amount
            else:
                if amount <= 0:
                    errtip.amount = '金额须大于零'
                elif amount >= 9999999:
                    errtip.amount = '金额超出上限'
                else:
                    amount_cent = amount * 100

        if not current_user:
            mail = self.get_argument('mail', '')
            if not mail:
                errtip.mail = '请输入联系邮箱'
            elif not EMAIL_VALID.match(mail):
                errtip.mail = '邮箱无效'
            else:
                user = user_by_mail(mail)
                self.set_cookie('E', mail.strip().lower())
                if not user:
                    user = user_new_by_mail(mail)
                elif user.state >= ZSITE_STATE_APPLY:
                    return self.redirect('/auth/login?next=%s' % request.uri)
                current_user = user

        if current_user and not errtip:
            subject = '%s 向 %s 捐赠 %.2f 元' % (current_user.name, zsite.name,
                                             amount)
            current_user_id = current_user.id
            balance_cent = bank.get(current_user_id)

            def _pay_new(state):
                return pay_new(amount, current_user_id, zsite_id,
                               CID_TRADE_PAY, state).id

            txt = self.get_argument('txt', None)
            secret = self.get_argument('secret', None)

            message = {}

            if title:
                message['title'] = title
            if url:
                message['url'] = url
            if txt:
                message['txt'] = txt
                if secret:
                    message['secret'] = secret

            if balance_cent >= amount_cent:
                o_id = _pay_new(TRADE_STATE_FINISH)
                if message:
                    trade_log.set(o_id, dumps(message))
                pay_notice(o_id)

                return self.redirect('%s/pay/result/%s' % (SITE_HTTP, o_id))
            elif balance_cent > 0:
                subject += '(余额支付 %.2f 元)' % (balance_cent / 100.0)
                o_id = _pay_new(TRADE_STATE_NEW)
                amount_cent -= balance_cent
            else:
                o_id = _pay_new(TRADE_STATE_NEW)

            trade_log.set(o_id, dumps(message))

            return_url = '%s/money/alipay_sync' % SITE_HTTP
            notify_url = '%s/money/alipay_async' % RPC_HTTP

            alipay_url = alipay_payurl_with_tax(current_user_id,
                                                amount_cent / 100.0,
                                                return_url, notify_url,
                                                subject, alipay_account, o_id)

            return self.redirect(alipay_url)

        self.render(url=url,
                    title=title,
                    amount=amount,
                    errtip=errtip,
                    alipay_account=alipay_account)