示例#1
0
def account_login():
    account_id = request.form.get('account_id')
    account_pw = request.form.get('account_pw')

    try:
        Account.login(account_id, account_pw)
    except AccountNotFound:
        return jsonify({'error': {'code': 'account_not_found'}}), 404
    except DoesNotMatchPassword:
        return jsonify({'error': {'code': 'does_not_match_password'}}), 403

    return jsonify({})
示例#2
0
def lecture_admin_administrators(year, term, code):
    from opencampus.module.account.models import Account
    lecture = Lecture.get_lecture(year, term, code)

    if request.method == 'POST':
        try:
            account = Account.objects(account_id=request.form.get('account_id')).get()
            if account.id not in lecture.admins:
                Lecture.objects(id=lecture.id).update_one(push__admins=account.id)
        except Account.DoesNotExist:
            pass

        lecture = Lecture.get_lecture(year, term, code)

    admins = [Account.objects(id=admin).get() for admin in lecture.admins]

    return render_template('module/lecture/detail/admin/administrators.html', year=year, term=term, code=code,
                           lecture=lecture, admins=admins)
示例#3
0
    def get_account(self):
        if len(self.db_session.account_list) < 1:
            return None

        account_oid = self.db_session.account_list[0]
        from opencampus.module.account.models import Account
        try:
            return Account.objects(id=account_oid).get()
        except Account.DoesNotExist:
            self.db_session.account_list = []
            self.modified = True
            return None
示例#4
0
def account_join():
    if request.method == 'GET':
        # TODO : move privacy_policy.txt
        privacy_policy = """수집하는 개인정보의 항목
오픈캠퍼스는 회원가입, 각종 서비스 등 기본적인 서비스 제공을 위한 필수정보와 고객 맞춤 서비스 제공을 위한 선택정보로 구분하여 아래와 같은 개인정보를 수집하고 있습니다.

1) 회원가입 / 본인인증을 위한 수집
필수항목 : 아이디, 비밀번호, 재학중인 학교, 학번, 학교 포탈 인증 정보

2) 서비스 제공을 위한 수집
필수항목 : 재학중인 학과, 수강신청 내역 등의 학교 포탈에 등록된 본인과 관련된 정보

3) 쿨하우스 연동 시
필수항목 : 쿨하우스 입주생 인증 정보

4) 서비스 이용 과정에서 아래와 같은 정보들이 자동으로 생성되어 수집될 수 있습니다.
IP Address, 쿠키, 방문 일시, 서비스 이용 기록, 불량 이용 기록, 기기정보

5) Google Analytics
사용하는 브라우저, 접속지역, 해상도, 운영체제 정보등이 수집되며 자세한 사항은 Google Analytics의 관련 페이지에서 확인할 수 있습니다.
또한 유저별 데이터 분석을 위해 Google Analytics User-ID 정책 따라 사용자 고유식별번호가 수집될 수 있습니다.

선택정보를 입력하지 않은 경우에도 서비스 이용 제한은 없으며 이용자의 기본적 인권 침해의 우려가 있는 민감한 개인 정보(인종, 사상 및 신조, 정치적 성향 이나 범죄기록, 의료정보 등)는 기본적으로 수집하지 않습니다.
다만 불가피하게 수집이 필요한 경우 반드시 사전에 동의 절차를 거치도록 하겠습니다.

개인정보의 수집 • 이용목적
오픈캠퍼스는 이용자의 소중한 개인정보를 다음과 같은 목적으로만 이용하며, 목적이 변경될 경우에는 '개인정보취급방침의 변경' 항목에 따라 고지됩니다.
회원으로 가입한 이용자를 식별하고 가입의사, 불량회원의 부정한 이용을 방지하기 위하여 사용합니다.
이용자에게 오픈캠퍼스의 다양한 서비스를 제공하고 서비스 이용 과정에서 이용자의 문의사항이나 불만을 처리하고 공지사항 등을 전달하기 위해 사용합니다.
이용자와 약속한 서비스를 제공하고 유료 서비스 구매 및 이용이 이루어지는 경우 이에 따른 요금 정산을 위해 사용됩니다.
신규 서비스가 개발되거나 이벤트 행사 시 참여기회를 알리기 위한 정보 전달 및 마케팅 및 광고 등에도 사용됩니다.
이용자의 서비스 이용 기록과 접속 빈도 분석 및 서비스 이용에 대한 통계, 이를 통한 맞춤형 서비스 제공과 서비스 개선에도 사용됩니다.

개인정보의 보유 • 이용기간
오픈캠퍼스는 이용자의 개인정보를 회원가입을 하는 시점부터 서비스를 제공하는 기간 동안에만 제한적으로 이용하고 있습니다. 이용자가 회원탈퇴를 요청하거나 제공한 개인정보의 수집 및 이용에 대한 동의를 철회하는 경우, 또는 수집 및 이용목적이 달성되거나 보유 및 이용기간이 종료한 경우 해당 이용자의 개인정보는 지체 없이 파기 됩니다.
그리고 관계법령의 규정에 따라 아래와 같이 관계 법령에서 정한 일정한 기간 동안 회원정보를 보관합니다.

서비스 이용 관련 개인정보 (접근 기록)
보존 근거 : 통신비밀보호법 보존 기간 : 3개월
        """
        return render_template('module/account/join/terms.html', privacy_policy=privacy_policy)

    # Ajax
    phase = request.form.get('phase')

    if phase == 'choice_auth':
        return render_template('module/account/join/choice_auth.html')

    elif phase == 'auth_portal':
        return render_template('module/account/join/auth_portal.html')

    elif phase == 'req_auth_portal':
        portal_id = request.form.get('portal_id')
        portal_pw = request.form.get('portal_pw')
        if not portal_id or not portal_pw:
            return render_template('module/account/join/auth_portal.html',
                                   req_auth=True, portal_id=portal_id, portal_pw=portal_pw)

        try:
            student_id = request.campus.get_gateway().get_student_id(portal_id, portal_pw)
            try:
                Account.objects(campus_id=request.campus.id, student_id=student_id).get()
                return render_template('module/account/join/auth_portal.html',
                                       req_auth=True, portal_id=portal_id, portal_pw=portal_pw,
                                       error='이미 회원가입되어있는 사용자입니다. 아이디 비밀번호 찾기를 이용해주세요.')
            except Account.DoesNotExist:
                pass

            session['join_req_data'] = {
                'type': 'auth_portal',
                'portal_id': portal_id,
                'portal_pw': portal_pw,
                'student_id': student_id
            }

            return render_template('module/account/join/join_form.html',
                                   portal_id=portal_id, portal_pw=portal_pw)

        except NotFoundPortalAccount:
            return render_template('module/account/join/auth_portal.html',
                                   req_auth=True, portal_id=portal_id, portal_pw=portal_pw,
                                   error='아이디 혹은 비밀번호가 다릅니다')
        except:
            return render_template('module/account/join/auth_portal.html',
                                   req_auth=True, portal_id=portal_id, portal_pw=portal_pw,
                                   error='포탈 서버와 통신 중 장애가 발생하였습니다. 신속히 해결하도록 하겠습니다.')

    elif phase == 'req_join':
        account_id = request.form.get('account_id')
        account_pw = request.form.get('account_pw')
        account_nick = request.form.get('account_nick')

        if not account_id or not account_pw or not account_nick:
            return render_template('module/account/join/join_form.html',
                                   error='잘못된 입력값',
                                   account_id=account_id, account_pw=account_pw, account_nick=account_nick)

        if not Account.valid_account_id(account_id):
            return render_template('module/account/join/join_form.html',
                                   error='아이디는 6~30자의 영문소문자, 숫자, -, _로 이루어져야 하며 영문 소문자로 시작되어야 합니다.',
                                   account_id=account_id, account_pw=account_pw, account_nick=account_nick)

        if not Account.valid_account_pw(account_pw):
            return render_template('module/account/join/join_form.html',
                                   error='비밀번호는 영문, 숫자, 특수문자를 조합하여 8자리 이상이여야합니다.',
                                   account_id=account_id, account_pw=account_pw, account_nick=account_nick)

        if not Account.valid_nickname(account_nick):
            return render_template('module/account/join/join_form.html',
                                   error='닉네임은 3~10자로 지정하여야 합니다.',
                                   account_id=account_id, account_pw=account_pw, account_nick=account_nick)

        if not session['join_req_data'] or not session['join_req_data']['student_id']:
            abort(403)

        try:
            Account.create_account(
                campus_id=request.campus.id,
                account_id=account_id,
                account_pw=account_pw,
                nickname=account_nick,
                account_type='default',
                student_id=session['join_req_data']['student_id']
            )

            request.campus.get_gateway().change_account_auth_info(session['join_req_data'])

            del session['join_req_data']
        except NotUniqueError:
            return render_template('module/account/join/join_form.html',
                                   error='이미 존재하는 아이디입니다.')

        return '<script type="text/javascript"> location.href="/"; </script>'
示例#5
0
def oauth2_authorize():
    client_id = request.args.get('client_id')
    redirect_uri = request.args.get('redirect_uri')
    response_type = request.args.get('response_type')
    scope = [scope.strip() for scope in request.args.get('scope', '').split(',')]

    if not (client_id and redirect_uri and response_type):
        return jsonify({'error': 'invalid_request'}), 400

    try:
        client = ApplicationOAuth2Client.objects(id=client_id).get()
    except ApplicationOAuth2Client.DoesNotExist:
        return jsonify({'error': 'unauthorized_client'}), 400

    check_redirect_uri = False
    for accept_redirect_uri in client.redirect_uris:
        if redirect_uri.startswith(accept_redirect_uri):
            check_redirect_uri = True

    if not check_redirect_uri:
        return 'redirect_uri error', 400

    if not session.get_account():
        if request.method == 'GET':
            return render_template('api/oauth2/login.html')
        else:
            account_id = request.form.get('account_id')
            account_pw = request.form.get('account_pw')

            from opencampus.module.account.models import Account
            try:
                Account.login(account_id, account_pw)
            except:
                return render_template('api/oauth2/login.html')

    check_accept = True
    try:
        accept = OAuth2AccountAccept.objects(client_id=client_id, account_id=session.get_account().id).get()
        for s in scope:
            if accept and s not in accept.scope:
                check_accept = False

    except OAuth2AccountAccept.DoesNotExist:
        check_accept = False
        accept = None

    if not check_accept:
        if request.method == 'GET':
            return render_template('api/oauth2/permission.html',
                                   app=Application.objects(id=client.application_id).get(),
                                   scope=scope,
                                   scope_name=SCOPE)
        elif request.method == 'POST':
            token = session.get('csrf_token')
            if not token or token != request.form.get('csrf_token'):
                return abort(403)

            if not accept:
                accept = OAuth2AccountAccept()
                accept.client_id = client_id
                accept.account_id = session.get_account().id
                accept.created_at = datetime.utcnow()

            accept.scope = scope
            accept.save()

    if response_type == 'token':
        token = OAuth2AccessToken.create_token('account', session.get_account().id, client_id=client.id, scope=accept.scope)
        token.save()
        return redirect(redirect_uri + '?access_token=' + token.access_token)
    elif response_type == 'code':
        code = OAuth2AuthorizationCode.create_code(client.id, session.get_account().id, scope=accept.scope)
        return redirect(redirect_uri + '?code=' + code.code)
    else:
        return jsonify({'error': 'unsupported_response_type'}), 400
示例#6
0
def lecture_admin_administrators_remove(year, term, code):
    from opencampus.module.account.models import Account
    account = Account.objects(account_id=request.form.get('account_id')).get()
    lecture = Lecture.get_lecture(year, term, code)
    Lecture.objects(id=lecture.id).update_one(pull__admins=account.id)
    return redirect(url_for('campus.lecture_admin_administrators', year=year, term=term, code=code))