def email_verified(request, token): useremail_id = cache.get(token + '_useremail_id') usermail = GsuserManager.get_useremail_by_id(useremail_id) if usermail and usermail.is_verify == 0 and usermail.user_id == request.user.id: usermail.is_verify = 1 usermail.save() return HttpResponseRedirect('/settings/emails/')
def email_verified(request, token): useremail_id = cache.get(token + '_useremail_id') usermail = GsuserManager.get_useremail_by_id(useremail_id) if usermail and usermail.is_verify == 0 and usermail.user_id == request.user.id: usermail.is_verify = 1 usermail.save() return HttpResponseRedirect('/settings/emails/')
def email_verify(request, eid): usermail = GsuserManager.get_useremail_by_id(eid) email = usermail.email via = '' if usermail and usermail.is_verify == 0 and usermail.user_id == request.user.id: Mailer().send_verify_email(request.user, eid, email) email_suffix = email.split('@')[-1] if email_suffix in COMMON_EMAIL_DOMAIN: via = COMMON_EMAIL_DOMAIN[email_suffix] return json_httpResponse({'code': 200, 'message': u'请尽快验证邮箱', 'via': via}) return json_httpResponse({'code': 500, 'message': u'邮箱不对,或者没有相关权限', 'via': via})
def email_primary(request, eid): usermail = GsuserManager.get_useremail_by_id(eid) if not usermail or usermail.user_id != request.user.id: return json_failed(500, u'设置失败,没有权限') useremails = GsuserManager.list_useremail_by_userId(request.user.id) for x in useremails: if usermail.id != x.id and x.is_primary == 1: x.is_primary = 0 x.save() usermail.is_primary = 1 usermail.save() return json_success(u'成功设置默认邮箱 %s' % usermail.email)
def email_primary(request, eid): usermail = GsuserManager.get_useremail_by_id(eid) if not usermail or usermail.user_id != request.user.id: return json_failed(500, u'设置失败,没有权限') useremails = GsuserManager.list_useremail_by_userId(request.user.id) for x in useremails: if usermail.id != x.id and x.is_primary == 1: x.is_primary = 0 x.save() usermail.is_primary = 1 usermail.save() return json_success(u'成功设置默认邮箱 %s' % usermail.email)
def email_verify(request, eid): usermail = GsuserManager.get_useremail_by_id(eid) email = usermail.email via = '' if usermail and usermail.is_verify == 0 and usermail.user_id == request.user.id: Mailer().send_verify_email(request.user, eid, email) email_suffix = email.split('@')[-1] if email_suffix in COMMON_EMAIL_DOMAIN: via = COMMON_EMAIL_DOMAIN[email_suffix] return json_httpResponse({ 'code': 200, 'message': u'请尽快验证邮箱', 'via': via }) return json_httpResponse({ 'code': 500, 'message': u'邮箱不对,或者没有相关权限', 'via': via })
def email_remove(request, eid): usermail = GsuserManager.get_useremail_by_id(eid) if usermail and usermail.user_id == request.user.id: usermail.visibly = 1 usermail.save() return json_success(u'成功删除邮箱 %s' % usermail.email)
def email_remove(request, eid): usermail = GsuserManager.get_useremail_by_id(eid) if usermail and usermail.user_id == request.user.id: usermail.visibly = 1 usermail.save() return json_success(u'成功删除邮箱 %s' % usermail.email)