def register(): from uliweb.contrib.auth import create_user, login form = functions.get_form('auth.RegisterForm')() if request.method == 'GET': form.next.data = request.GET.get('next', add_prefix('/')) return {'form':form, 'msg':''} if request.method == 'POST': flag = form.validate(request.params) if flag: from uliweb import settings f, d = create_user(username=form.username.data, password=form.password.data, auth_type=settings.AUTH.AUTH_TYPE_DEFAULT) if f: #add auto login support 2012/03/23 login(d) next = urllib.unquote(request.POST.get('next', add_prefix('/'))) return redirect(next) else: form.errors.update(d) msg = form.errors.get('_', '') or _('Register failed!') return {'form':form, 'msg':str(msg)}
def handle(self, options, global_options, *args): from getpass import getpass from uliweb.contrib.auth import create_user from uliweb import settings self.get_application(global_options) User = get_model("user") if not options.username: print >> sys.stderr, "error: username required" sys.exit(ERR_BAD_PARAM) if User.get(User.c.username == options.username): print >> sys.stderr, "error: same username user exists already" sys.exit(ERR_BAD_PARAM) password = "" while (not password): password = getpass("input the password:"******"user '%s' created successfully" % (options.username) else: print >> sys.stderr, "fail to create user '%s', error: %s" % ( options.username, d.get("_", ""))
def handle(self, options, global_options, *args): from getpass import getpass from uliweb.contrib.auth import create_user from uliweb import settings self.get_application(global_options) User = get_model("user") if not options.username: print >> sys.stderr, "error: username required" sys.exit(ERR_BAD_PARAM) if User.get(User.c.username==options.username): print >> sys.stderr, "error: same username user exists already" sys.exit(ERR_BAD_PARAM) password = "" while (not password): password = getpass("input the password:"******"user '%s' created successfully"%(options.username) else: print >> sys.stderr, "fail to create user '%s', error: %s"%(options.username,d.get("_",""))
def register(): from uliweb import settings from uliweb.contrib.auth import create_user, login if not settings.LOGIN.register: error('不允许用户自行注册') next = request.values.get('next') if not next: next = request.referrer if not next or (next and next.endswith('/register')): next = add_prefix('/') form = functions.get_form('auth.RegisterForm')() if request.method == 'GET': form.next.data = next return {'form': form, 'msg': ''} if request.method == 'POST': flag = form.validate(request.values) if flag: from uliweb import settings f, d = create_user(username=form.username.data, password=form.password.data, auth_type=settings.AUTH.AUTH_TYPE_DEFAULT) if f: # add auto login support 2012/03/23 login(d) next = unquote(next) return redirect(next) else: form.errors.update(d) if request.is_xhr: return json({ 'success': False, '_': 'Register Failed', 'errors': form.errors }) else: msg = form.errors.get('_', '') or _('Register failed!') return {'form': form, 'msg': str(msg)}
def register(): from uliweb.contrib.auth import create_user from forms import RegisterForm form = RegisterForm() if request.method == 'GET': form.next.data = request.GET.get('next', '/') return {'form':form, 'msg':''} if request.method == 'POST': flag = form.validate(request.params) if flag: f, d = create_user(username=form.username.data, password=form.password.data) if f: next = request.POST.get('next', '/') return redirect(next) else: form.errors.update(d) msg = form.errors.get('_', '') or _('Register failed!') return {'form':form, 'msg':str(msg)}
def register(): from uliweb import settings from uliweb.contrib.auth import create_user, login if not settings.LOGIN.register: error('不允许用户自行注册') next = request.values.get('next') if not next: next = request.referrer if not next or (next and next.endswith('/register')): next = add_prefix('/') form = functions.get_form('auth.RegisterForm')() if request.method == 'GET': form.next.data = next return {'form': form, 'msg': ''} if request.method == 'POST': flag = form.validate(request.values) if flag: from uliweb import settings f, d = create_user(username=form.username.data, password=form.password.data, auth_type=settings.AUTH.AUTH_TYPE_DEFAULT) if f: # add auto login support 2012/03/23 login(d) next = unquote(next) return redirect(next) else: form.errors.update(d) if request.is_xhr: return json({'success': False, '_': 'Register Failed', 'errors': form.errors}) else: msg = form.errors.get('_', '') or _('Register failed!') return {'form': form, 'msg': str(msg)}
def register(self): from uliweb.contrib.auth import create_user, login from uliweb.i18n import ugettext_lazy as _ form = functions.get_form('RegisterForm')() if request.method == 'GET': form.next.data = request.GET.get('next', '/') return {'form':form, 'msg':''} if request.method == 'POST': flag = form.validate(request.params) if flag: f, d = create_user(username=form.username.data, password=form.password.data,email=form.email.data) if f: #add auto login support 2012/03/23 login(d) next = urllib.unquote(request.POST.get('next', '/')) return redirect(next) else: form.errors.update(d) msg = form.errors.get('_', '') or _('Register failed!') return {'form':form, 'msg':str(msg)}