def _get_account_name(self, request, form, msg=None): # now we need to ask the user for a new username # that they want to use on this wiki # XXX: request nickname from OP and suggest using it # (if it isn't in use yet) logging.debug("running _get_account_name") _ = request.getText form.append(html.INPUT(type='hidden', name='oidstage', value='2')) table = html.TABLE(border='0') form.append(table) td = html.TD(colspan=2) td.append( html.Raw( _("""Please choose an account name now. If you choose an existing account name you will be asked for the password and be able to associate the account with your OpenID."""))) table.append(html.TR().append(td)) if msg: td = html.TD(colspan='2') td.append(html.P().append(html.STRONG().append(html.Raw(msg)))) table.append(html.TR().append(td)) td1 = html.TD() td1.append(html.STRONG().append(html.Raw(_('Name')))) td2 = html.TD() td2.append(html.INPUT(type='text', name='username')) table.append(html.TR().append(td1).append(td2)) td1 = html.TD() td2 = html.TD() td2.append( html.INPUT(type='submit', name='submit', value=_('Choose this name'))) table.append(html.TR().append(td1).append(td2))
def _create_form(request): _ = request.getText url = request.page.url(request) ret = html.FORM(action=url) ret.append(html.INPUT(type='hidden', name='action', value='recoverpass')) lang_attr = request.theme.ui_lang_attr() ret.append(html.Raw('<div class="userpref"%s>' % lang_attr)) tbl = html.TABLE(border="0") ret.append(tbl) ret.append(html.Raw('</div>')) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append(html.Text( _("Username"))))) row.append(html.TD().append(html.INPUT(type="text", size="36", name="name"))) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append(html.Text(_("Email"))))) row.append(html.TD().append( html.INPUT(type="text", size="36", name="email"))) row = html.TR() tbl.append(row) row.append(html.TD()) td = html.TD() row.append(td) td.append( html.INPUT(type="submit", name="account_sendmail", value=_('Mail me my account data'))) return unicode(ret)
def _associate_account(self, request, form, accountname, msg=None): _ = request.getText form.append(html.INPUT(type='hidden', name='oidstage', value='3')) table = html.TABLE(border='0') form.append(table) td = html.TD(colspan=2) td.append( html.Raw( _("""The username you have chosen is already taken. If it is your username, enter your password below to associate the username with your OpenID. Otherwise, please choose a different username and leave the password field blank."""))) table.append(html.TR().append(td)) if msg: td.append(html.P().append(html.STRONG().append(html.Raw(msg)))) td1 = html.TD() td1.append(html.STRONG().append(html.Raw(_('Name')))) td2 = html.TD() td2.append(html.INPUT(type='text', name='username', value=accountname)) table.append(html.TR().append(td1).append(td2)) td1 = html.TD() td1.append(html.STRONG().append(html.Raw(_('Password')))) td2 = html.TD() td2.append(html.INPUT(type='password', name='password')) table.append(html.TR().append(td1).append(td2)) td1 = html.TD() td2 = html.TD() td2.append( html.INPUT(type='submit', name='submit', value=_('Associate this name'))) table.append(html.TR().append(td1).append(td2))
def _create_token_form(request, name=None, token=None): _ = request.getText url = request.page.url(request) ret = html.FORM(action=url) ret.append(html.INPUT(type='hidden', name='action', value='recoverpass')) lang_attr = request.theme.ui_lang_attr() ret.append(html.Raw('<div class="userpref"%s>' % lang_attr)) tbl = html.TABLE(border="0") ret.append(tbl) ret.append(html.Raw('</div>')) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append( html.Text(_("Recovery token"))))) value = token or '' row.append(html.TD().append( html.INPUT(type='text', size="36", name="token", value=value))) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append(html.Text( _("Username"))))) value = name or '' row.append(html.TD().append( html.INPUT(type='text', size="36", name="name", value=value))) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append( html.Text(_("New password"))))) row.append(html.TD().append( html.INPUT(type="password", size="36", name="password"))) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append( html.Text(_("New password (repeat)"))))) row.append(html.TD().append( html.INPUT(type="password", size="36", name="password_repeat"))) row = html.TR() tbl.append(row) row.append(html.TD()) td = html.TD() row.append(td) td.append( html.INPUT(type="submit", name="recover", value=_('Reset my password'))) return unicode(ret)
def _make_row(self, label, cell, **kw): """ Create a row in the form table. """ self._table.append(html.TR().extend([ html.TD(**kw).extend([html.B().append(label), ' ']), html.TD().extend(cell), ]))
def _event_select(self): """ Create event subscription list. """ _ = self._ types = [] if self.cfg.mail_enabled and self.request.user.email: types.append(('email', _("'''Email'''", wiki=True))) if self.cfg.jabber_enabled and self.request.user.jid: types.append(('jabber', _("'''Jabber'''", wiki=True))) table = html.TABLE() header = html.TR() table.append(header) for name, descr in types: header.append(html.TH().append(html.Raw(descr))) header.append( html.TH(align='left').append( html.Raw(_("'''Event type'''", wiki=True)))) event_list = events.get_subscribable_events() super = self.request.user.isSuperUser() # Create a list of (value, name) tuples for display as radiobuttons # Only include super-user visible events if current user has these rights. # It's cosmetic - the check for super-user rights should be performed # in event handling code as well! allowed = [] for key in event_list.keys(): if not event_list[key]['superuser'] or super: allowed.append((key, event_list[key]['desc'])) for evname, evdescr in allowed: tr = html.TR() table.append(tr) for notiftype, notifdescr in types: checked = evname in getattr(self.request.user, '%s_subscribed_events' % notiftype) tr.append(html.TD().append( html.INPUT(type='checkbox', checked=checked, name='subscribe:%s:%s' % (notiftype, evname)))) tr.append(html.TD().append(html.Raw( self.request.getText(evdescr)))) return table
def create_form(self, create_only=False, recover_only=False): r = self.request ss = self.cfg.session_service format_time = lambda x: self.request.user.getFormattedDateTime( x) if x else x form = self.make_form(html.Text("Active sessions for your account")) ticket = wikiutil.createTicket(self.request) form.append( html.INPUT(type="hidden", name="ticket", value="%s" % ticket)) self._table.append(html.TR().extend([ html.TD().extend([""]), html.TD().extend([html.B().append("From IP")]), html.TD().extend([html.B().append("Login Date")]), html.TD().extend([html.B().append("Expiration")]), html.TD().extend([html.B().append("User Agent")]), ])) for sid in ss.get_all_session_ids(r): session = ss.get_session(r, sid) if session.get("user.id") != r.user.id: continue self._table.append(html.TR().extend([ html.TD().extend( [html.INPUT(type="checkbox", name="session.%s" % sid)]), html.TD().extend([session.get("from_ip")]), html.TD().extend([format_time(session.get("started"))]), html.TD().extend([format_time(session.get("expires"))]), html.TD().extend([session.get("from_ua")]), ])) form.append( unicode( html.INPUT(type="submit", name='save', value="Delete Sessions"))) form.append( unicode(html.INPUT(type="submit", name='cancel', value="Cancel"))) #form.append(repr(r.in_headers)) return unicode(form)
def _create_form(request): _ = request.getText url = request.page.url(request) ret = html.FORM(action=url) ret.append( html.INPUT(type='hidden', name='action', value='CreateNewAccount')) lang_attr = request.theme.ui_lang_attr() ret.append(html.Raw('<div class="userpref"%s>' % lang_attr)) tbl = html.TABLE(border="0") ret.append(tbl) ret.append(html.Raw('</div>')) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append(html.Text(_("Name"))))) cell = html.TD() row.append(cell) cell.append(html.INPUT(type="text", size="36", name="name")) cell.append(html.Text(' ' + _("(Use FirstnameLastname)"))) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append(html.Text( _("Password"))))) row.append(html.TD().append( html.INPUT(type="password", size="36", name="password1"))) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append( html.Text(_("Password repeat"))))) row.append(html.TD().append( html.INPUT(type="password", size="36", name="password2"))) row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append(html.Text(_("Email"))))) row.append(html.TD().append( html.INPUT(type="text", size="36", name="email"))) textcha = TextCha(request) if textcha.is_enabled(): row = html.TR() tbl.append(row) row.append(html.TD().append(html.STRONG().append( html.Text(_('TextCha (required)'))))) td = html.TD() if textcha: td.append(textcha.render()) row.append(td) row = html.TR() tbl.append(row) row.append(html.TD()) td = html.TD() row.append(td) td.append( html.INPUT(type="submit", name="create", value=_('Create Profile'))) return unicode(ret)
def show_decide_page(self, identity, username, openidreq): request = self.request _ = self._ if not request.user.valid or username != request.user.name: request.makeForbidden(403, _('''You need to manually go to your OpenID provider wiki and log in before you can use your OpenID. MoinMoin will never allow you to enter your password here. Once you have logged in, simply reload this page.''')) return request.theme.send_title(_("OpenID Trust verification"), pagename=request.page.page_name) # Start content (important for RTL support) request.write(request.formatter.startContent("content")) request.write(request.formatter.paragraph(1)) request.write(_('The site %s has asked for your identity.') % openidreq.trust_root) request.write(request.formatter.paragraph(0)) request.write(request.formatter.paragraph(1)) request.write(_(''' If you approve, the site represented by the trust root below will be told that you control the identity URL %s. (If you are using a delegated identity, the site will take care of reversing the delegation on its own.)''') % openidreq.identity) request.write(request.formatter.paragraph(0)) form = html.FORM(method='POST', action=request.page.url(request)) form.append(html.INPUT(type='hidden', name='action', value='serveopenid')) form.append(html.INPUT(type='hidden', name='openid.identity', value=openidreq.identity)) form.append(html.INPUT(type='hidden', name='openid.return_to', value=openidreq.return_to)) form.append(html.INPUT(type='hidden', name='openid.trust_root', value=openidreq.trust_root)) form.append(html.INPUT(type='hidden', name='openid.mode', value=openidreq.mode)) form.append(html.INPUT(type='hidden', name='name', value=username)) nonce = randomString(32, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') form.append(html.INPUT(type='hidden', name='nonce', value=nonce)) request.session['openidserver.nonce'] = nonce table = html.TABLE() form.append(table) tr = html.TR() table.append(tr) tr.append(html.TD().append(html.STRONG().append(html.Text(_('Trust root'))))) tr.append(html.TD().append(html.Text(openidreq.trust_root))) tr = html.TR() table.append(tr) tr.append(html.TD().append(html.STRONG().append(html.Text(_('Identity URL'))))) tr.append(html.TD().append(html.Text(identity))) tr = html.TR() table.append(tr) tr.append(html.TD().append(html.STRONG().append(html.Text(_('Name'))))) tr.append(html.TD().append(html.Text(username))) tr = html.TR() table.append(tr) tr.append(html.TD().append(html.STRONG().append(html.Text(_('Remember decision'))))) td = html.TD() tr.append(td) td.append(html.INPUT(type='checkbox', name='remember', value='yes')) td.append(html.Text(_('Remember this trust decision and don\'t ask again'))) tr = html.TR() table.append(tr) tr.append(html.TD()) td = html.TD() tr.append(td) td.append(html.INPUT(type='submit', name='approve', value=_("Approve"))) td.append(html.INPUT(type='submit', name='dontapprove', value=_("Don't approve"))) request.write(unicode(form)) request.write(request.formatter.endContent()) request.theme.send_footer(request.page.page_name) request.theme.send_closing_html()