Ejemplo n.º 1
0
def passwd_ftp(request, ftp_id):
    iftp = get_object_or_404(Ftp, id=ftp_id)
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    if request.method == 'POST':
        form = PassCheckForm(request.POST)
        
        if form.is_valid():
            if iftp.owner != u:
                return HttpResponseForbidden(ugettext("Unable to edit chosen account"))

            iftp.password = crypt.crypt(form.cleaned_data["password1"], iftp.owner.username)
            iftp.save()
            #iftp.password = crypt.crypt(form.cleaned_data["password1"], iftp.owner.username)
            messages.add_message(request, messages.SUCCESS, _('Password has been changed'))
            return HttpResponseRedirect(reverse("ftp_list"))
    else:
        form = PassCheckForm()

    return render_to_response('universal.html',
            {
            "form": form,
            "form_helper": RostiFormHelper(),
            "title": _("Edit FTP account"),
            "submit": _("Save changes"),
            "action": reverse("ftp_passwd", kwargs={'ftp_id': ftp_id}),
            "u": u,
            "superuser": superuser,
            "menu_active": "ftps",
            },
        context_instance=RequestContext(request)
    )
Ejemplo n.º 2
0
def change_passwd(request):
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    if request.method == 'POST':
        form = PassCheckForm(request.POST)
        if form.is_valid():
            u.set_password(form.cleaned_data["password1"])
            u.save()

            messages.add_message(request, messages.SUCCESS, _('Password has been changed'))
            return HttpResponseRedirect(reverse("wsgiadmin.useradmin.views.change_passwd"))
    else:
        form = PassCheckForm()

    return render_to_response('universal.html',
            {
            "form": form,
            "form_helper": RostiFormHelper(),
            "title": _("Change password for this administration"),
            "u": u,
            "superuser": superuser,
            "menu_active": "settings",
            },
        context_instance=RequestContext(request)
    )
Ejemplo n.º 3
0
def passwd_ftp(request, ftp_id):
    iftp = get_object_or_404(Ftp, id=ftp_id)
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    if request.method == 'POST':
        form = PassCheckForm(request.POST)

        if form.is_valid():
            if iftp.owner != u:
                return HttpResponseForbidden(
                    ugettext("Unable to edit chosen account"))

            iftp.password = crypt.crypt(form.cleaned_data["password1"],
                                        iftp.owner.username)
            iftp.save()
            #iftp.password = crypt.crypt(form.cleaned_data["password1"], iftp.owner.username)
            messages.add_message(request, messages.SUCCESS,
                                 _('Password has been changed'))
            return HttpResponseRedirect(reverse("ftp_list"))
    else:
        form = PassCheckForm()

    return render_to_response(
        'universal.html', {
            "form": form,
            "title": _("Edit FTP account"),
            "submit": _("Save changes"),
            "action": reverse("ftp_passwd", kwargs={'ftp_id': ftp_id}),
            "u": u,
            "superuser": superuser,
            "menu_active": "ftps",
        },
        context_instance=RequestContext(request))
Ejemplo n.º 4
0
def change_passwd(request):
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    if request.method == 'POST':
        form = PassCheckForm(request.POST)
        if form.is_valid():
            u.set_password(form.cleaned_data["password1"])
            u.save()

            messages.add_message(request, messages.SUCCESS,
                                 _('Password has been changed'))
            return HttpResponseRedirect(
                reverse("wsgiadmin.useradmin.views.change_passwd"))
    else:
        form = PassCheckForm()

    return render_to_response(
        'universal.html', {
            "form": form,
            "form_helper": RostiFormHelper(),
            "title": _("Change password for this administration"),
            "u": u,
            "superuser": superuser,
            "menu_active": "settings",
        },
        context_instance=RequestContext(request))
Ejemplo n.º 5
0
def ssh_passwd(request):
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    if request.method == 'POST':
        form = PassCheckForm(request.POST)
        if form.is_valid():
            sr = SystemRequest(u, u.parms.web_machine)
            sr.passwd(form.cleaned_data["password1"])

            messages.add_message(request, messages.SUCCESS, _('Password has been changed'))
            return HttpResponseRedirect(reverse("wsgiadmin.useradmin.views.ok"))
    else:
        form = PassCheckForm()

    return render_to_response('universal.html',
            {
            "form": form,
            "title": _(u"Change password for SSH/FTP"),
            "submit": _(u"Change password"),
            "action": reverse("wsgiadmin.users.views.ssh_passwd"),
            "u": u,
            "superuser": superuser,
            "menu_active": "settings",
            },
                              context_instance=RequestContext(request)
    )
Ejemplo n.º 6
0
def passwd(request, dbtype, dbname):
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    if request.method == 'POST':
        form = PassCheckForm(request.POST)
        if form.is_valid():
            if dbtype == 'mysql':
                #TODO - raise better exception
                try:
                    m = u.mysqldb_set.get(dbname=dbname)
                except MySQLDB.DoesNotExist:
                    return HttpResponseForbidden(
                        ugettext("Unable to modify chosen database"))
                else:
                    mr = MySQLRequest(u, u.parms.mysql_machine)
            elif dbtype == 'pgsql':
                try:
                    m = u.pgsql_set.get(dbname=dbname)
                except PGSQL.DoesNotExist:
                    return HttpResponseForbidden(
                        ugettext("Unable to modify chosen database"))
                else:
                    mr = PostgreSQLRequest(u, u.parms.pgsql_machine)
            else:
                return HttpResponseBadRequest(_('Unknown database type'))

            mr.passwd_db(dbname, dbname)
            messages.add_message(request, messages.SUCCESS,
                                 _('Password has been changed'))
            return HttpResponseRedirect(
                reverse('db_list', kwargs=dict(dbtype=dbtype)))
    else:
        form = PassCheckForm()

    return render_to_response('simplepasswd.html', {
        'dbtype':
        dbtype,
        "form":
        form,
        "dbname":
        dbname,
        "title":
        _("Password for database %s") % dbname,
        "submit":
        _("Change password"),
        "action":
        reverse("db_passwd", kwargs=dict(dbtype=dbtype, dbname=dbname)),
        "u":
        u,
        "superuser":
        superuser,
        "menu_active":
        "dbs",
    },
                              context_instance=RequestContext(request))
Ejemplo n.º 7
0
def passwd(request, dbtype, dbname):
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    if request.method == 'POST':
        form = PassCheckForm(request.POST)
        if form.is_valid():
            if dbtype == 'mysql':
                #TODO - raise better exception
                try:
                    m = u.mysqldb_set.get(dbname=dbname)
                except MySQLDB.DoesNotExist:
                    return HttpResponseForbidden(ugettext("Unable to modify chosen database"))
                else:
                    mr = MySQLRequest(u, u.parms.mysql_machine)
            elif dbtype == 'pgsql':
                try:
                    m = u.pgsql_set.get(dbname=dbname)
                except PGSQL.DoesNotExist:
                    return HttpResponseForbidden(ugettext("Unable to modify chosen database"))
                else:
                    mr = PostgreSQLRequest(u, u.parms.pgsql_machine)
            else:
                return HttpResponseBadRequest(_('Unknown database type'))

            mr.passwd_db(dbname, dbname)
            messages.add_message(request, messages.SUCCESS, _('Password has been changed'))
            return HttpResponseRedirect(reverse('db_list', kwargs=dict(dbtype=dbtype)))
    else:
        form = PassCheckForm()

    return render_to_response('simplepasswd.html',
            {
            'dbtype': dbtype,
            "form": form,
            "dbname": dbname,
            "title": _("Password for database %s") % dbname,
            "submit": _("Change password"),
            "action": reverse("db_passwd", kwargs=dict(dbtype=dbtype, dbname=dbname)),
            "u": u,
            "superuser": superuser,
            "menu_active": "dbs",
            },
        context_instance=RequestContext(request)
    )