Example #1
0
def signup(request):
    if request.method == "POST":
        user = UserModel(username=request.POST['username'],
                         name=request.POST.get('username'),
                         role='instructor')
        user.set_password(request.POST['password'])
        user.save()
        return HttpResponseRedirect('/')
    return render(request, 'registration/signup.html')
Example #2
0
def signup(request):
    if request.method == "POST":
        print request.POST
        user = UserModel(username=request.POST['username'],
                         last_name=request.POST.get('last_name'),
                         first_name=request.POST.get('first_name'))
        user.set_password(request.POST['password'])
        user.save()
    return render(request, 'registration/signup.html')
Example #3
0
    def post(self):
        '''
        Create a new user
        '''
        args = user_parser.parse_args()

        if UserModel.find_by_email(args['email']):
            return {"message": "Email is already registered."}, 400

        new_user = UserModel(fname=args['fname'],
                             lname=args['lname'],
                             username=args['username'],
                             email=args['email'])

        new_user.set_password(args['password'])
        new_user.save_to_db()

        result = api_ns.marshal(new_user, user_model)

        return result, http.client.CREATED
    def create(self, validated_data):
        user = UserModel(email=validated_data["email"])
        user.set_password(validated_data["password"])
        user.save()

        return user