示例#1
0
文件: user.py 项目: ricky/supysonic
def lastfm_reg(uid, user):
    token = request.args.get('token')
    if token in ('', None):
        flash('Missing LastFM auth token')
        return redirect(url_for('user_profile', uid = uid))

    lfm = LastFm(app.config['LASTFM'], user, app.logger)
    status, error = lfm.link_account(token)
    store.commit()
    flash(error if not status else 'Successfully linked LastFM account')

    return redirect(url_for('user_profile', uid = uid))
示例#2
0
def lastfm_reg():
	token = request.args.get('token')
	if token in ('', None):
		flash('Missing LastFM auth token')
		return redirect(url_for('user_profile'))

	lfm = LastFm(UserManager.get(store, session.get('userid'))[1], app.logger)
	status, error = lfm.link_account(token)
	store.commit()
	flash(error if not status else 'Successfully linked LastFM account')

	return redirect(url_for('user_profile'))
示例#3
0
文件: user.py 项目: hhm0/supysonic
def lastfm_reg(uid):
	token = request.args.get('token')
	if token in ('', None):
		flash('Missing LastFM auth token')
		return redirect(url_for('user_profile', uid = uid))

	if uid == 'me':
		lfm = LastFm(UserManager.get(store, session.get('userid'))[1], app.logger)
	else:
		if not UserManager.get(store, session.get('userid'))[1].admin or not UserManager.get(store, uid)[0] is UserManager.SUCCESS:
			return redirect(url_for('index'))
		lfm = LastFm(UserManager.get(store, uid)[1], app.logger)
	status, error = lfm.link_account(token)
	store.commit()
	flash(error if not status else 'Successfully linked LastFM account')

	return redirect(url_for('user_profile', uid = uid))