Ticket #1890: authen.diff
| File authen.diff, 5.1 kB (added by maxb1@…, 3 years ago) |
|---|
-
./wiki/web_ui.py
old new 25 25 from trac.perm import IPermissionRequestor 26 26 from trac.Search import ISearchSource, query_to_sql, shorten_result 27 27 from trac.Timeline import ITimelineEventProvider 28 from trac.util import enum, format_datetime, get_reporter_id, \28 from trac.util import enum, format_datetime, get_reporter_id, get_authentic_id, \ 29 29 pretty_timedelta, shorten_line, Markup 30 30 from trac.versioncontrol.diff import get_diff_options, hdf_diff 31 31 from trac.web.chrome import add_link, add_stylesheet, INavigationContributor … … 183 183 # WIKI_ADMIN 184 184 page.readonly = int(req.args.has_key('readonly')) 185 185 186 page.save( req.args.get('author'), req.args.get('comment'),186 page.save(get_authentic_id(req, 'author'), req.args.get('comment'), 187 187 req.remote_addr) 188 188 req.redirect(self.env.href.wiki(page.name)) 189 189 … … 283 283 if preview: 284 284 page.readonly = req.args.has_key('readonly') 285 285 286 author = req.args.get('author', get_reporter_id(req))286 author = get_reporter_id(req, 'author') 287 287 comment = req.args.get('comment', '') 288 288 editrows = req.args.get('editrows') 289 289 if editrows: -
./ticket/web_ui.py
old new 84 84 85 85 ticket = Ticket(self.env, db=db) 86 86 ticket.populate(req.args) 87 ticket.values .setdefault('reporter', util.get_reporter_id(req))87 ticket.values['reporter'] = util.get_reporter_id(req, 'reporter') 88 88 89 89 if ticket.values.has_key('description'): 90 90 description = wiki_to_html(ticket['description'], self.env, req, db) … … 133 133 raise TracError('Tickets must contain a summary.') 134 134 135 135 ticket = Ticket(self.env, db=db) 136 ticket.values.setdefault('reporter', util.get_reporter_id(req))137 136 ticket.populate(req.args) 137 ticket.values['reporter'] = util.get_authentic_id(req, 'reporter') 138 138 ticket.insert(db=db) 139 139 db.commit() 140 140 … … 182 182 id = int(req.args.get('id')) 183 183 184 184 ticket = Ticket(self.env, id, db=db) 185 reporter_id = util.get_reporter_id(req )185 reporter_id = util.get_reporter_id(req, 'author') 186 186 187 187 if req.method == 'POST': 188 188 if not req.args.has_key('preview'): … … 195 195 req.hdf['ticket.reassign_owner'] = req.args.get('reassign_owner') \ 196 196 or req.authname 197 197 req.hdf['ticket.resolve_resolution'] = req.args.get('resolve_resolution') 198 reporter_id = req.args.get('author')199 198 comment = req.args.get('comment') 200 199 if comment: 201 200 req.hdf['ticket.comment'] = comment … … 343 342 ticket['resolution'] = '' 344 343 345 344 now = int(time.time()) 346 ticket.save_changes( req.args.get('author', req.authname),345 ticket.save_changes(util.get_authentic_id(req, 'author'), 347 346 req.args.get('comment'), when=now, db=db) 348 347 db.commit() 349 348 -
./attachment.py
old new 318 318 'utf-8')).encode('utf-8') 319 319 320 320 attachment.description = req.args.get('description', '') 321 attachment.author = req.args.get('author', '')321 attachment.author = util.get_authentic_id(req, 'author') 322 322 attachment.ipnr = req.remote_addr 323 323 if req.args.get('replace'): 324 324 try: … … 376 376 text, link = self._get_parent_link(attachment) 377 377 req.hdf['attachment'] = { 378 378 'mode': 'new', 379 'author': util.get_reporter_id(req ),379 'author': util.get_reporter_id(req, 'author'), 380 380 'parent': {'type': attachment.parent_type, 381 381 'id': attachment.parent_id, 'name': text, 'href': link} 382 382 } -
./util.py
old new 334 334 raise Exception('Failed to create unique name: ' + path) 335 335 path = '%s.%d%s' % (parts[0], idx, parts[1]) 336 336 337 def get_reporter_id(req ):337 def get_reporter_id(req, argname=None): 338 338 name = req.session.get('name', None) 339 339 email = req.session.get('email', None) 340 340 341 if argname: 342 r = req.args.get(argname) 343 if r: 344 return r 345 341 346 if req.authname != 'anonymous': 342 347 return req.authname 343 348 elif name and email: … … 347 352 else: 348 353 return req.authname 349 354 355 def get_authentic_id(req, argname): 356 r = get_reporter_id(req, argname) 357 if req.authname == 'anonymous': 358 return r + ' [unauthenticated]' 359 else: 360 if r == req.authname: 361 return r 362 else: 363 return '%s (%s)' % (req.authname, r) 364 350 365 # Date/time utilities 351 366 352 367 def format_datetime(t=None, format='%x %X', gmt=False):
