Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

issues25489
caishi 6 years ago
commit 1e4c21c86d

@ -78,12 +78,17 @@ class AccountsController < ApplicationController
return normal_status(-2, "违反平台使用规范,账号已被锁定") if @user.locked? return normal_status(-2, "违反平台使用规范,账号已被锁定") if @user.locked?
login_control = LimitForbidControl::UserLogin.new(@user) login_control = LimitForbidControl::UserLogin.new(@user)
return normal_status(-2, "登录密码出错已达上限,将锁定密码1小时") if login_control.forbid? return normal_status(-2, "登录密码出错已达上限,账号已被锁定, 请#{login_control.forbid_expires/60}分钟后重新登录或找回登录密码,") if login_control.forbid?
password_ok = @user.check_password?(params[:password].to_s) password_ok = @user.check_password?(params[:password].to_s)
unless password_ok unless password_ok
if login_control.remain_times-1 == 0
normal_status(-2, "连续输错密码达到#{login_control.error_times+1}次,账号将被锁定")
else
normal_status(-2, "你已经输错密码#{login_control.error_times+1}次,还剩余#{login_control.remain_times-1}次机会")
end
login_control.increment! login_control.increment!
return normal_status(-2, "错误的账号或密码") return
end end
successful_authentication(@user) successful_authentication(@user)
@ -111,9 +116,11 @@ class AccountsController < ApplicationController
return normal_status(-2, "验证码已失效") if !verifi_code&.effective? return normal_status(-2, "验证码已失效") if !verifi_code&.effective?
user.password, user.password_confirmation = params[:new_password], params[:new_password_confirmation] user.password, user.password_confirmation = params[:new_password], params[:new_password_confirmation]
if user.save! ActiveRecord::Base.transaction do
sucess_status user.save!
LimitForbidControl::UserLogin.new(user).clear
end end
sucess_status
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("密码重置失败") tip_exception("密码重置失败")

@ -40,6 +40,14 @@ class LimitForbidControl::Base
end end
end end
def error_times
Rails.cache.read(cache_key).to_i
end
def remain_times
allow_times - error_times
end
def clear def clear
Rails.logger.info("[LimitForbidControl] Clear #{cache_key}") Rails.logger.info("[LimitForbidControl] Clear #{cache_key}")
Rails.cache.delete(forbid_cache_key) Rails.cache.delete(forbid_cache_key)

@ -12,7 +12,7 @@ class LimitForbidControl::UserLogin < LimitForbidControl::Base
def forbid_expires def forbid_expires
num = EduSetting.get('daily_error_password_forbid_time').presence.to_i num = EduSetting.get('daily_error_password_forbid_time').presence.to_i
num.zero? ? 1.hours : num.to_i.hours num.zero? ? 1.hours : num.to_i.minutes
end end
def cumulative_expires def cumulative_expires

@ -399,4 +399,8 @@
.color000{ .color000{
color: #000; color: #000;
}
.cursorpointer{
cursor: pointer;
} }

@ -224,6 +224,18 @@ class CompetitionCommon extends Component{
Competitionedittype:false Competitionedittype:false
}) })
}
newgotocourse=(url)=>{
if(this.props.checkIfLogin()===false){
this.props.showLoginDialog()
return
}
if(this.props.checkIfProfileCompleted()===false){
this.props.showProfileCompleteDialog()
return
}
window.open(url);
} }
gotocourse=(url)=>{ gotocourse=(url)=>{
@ -255,7 +267,9 @@ class CompetitionCommon extends Component{
).then((response) => { ).then((response) => {
if (response.data.status === 0) { if (response.data.status === 0) {
// this.props.history.replace(); // this.props.history.replace();
this.Personalregistration(`/courses/${data.course_id}`) this.getbannerdata()
window.open(`/courses/${data.course_id}`);
} }
}) })
@ -267,7 +281,7 @@ class CompetitionCommon extends Component{
let urls = `/competitions/${this.props.match.params.identifier}/enroll`; let urls = `/competitions/${this.props.match.params.identifier}/enroll`;
this.Personalregistration(urls) this.Personalregistration(urls)
} else { } else {
this.props.history.replace(url); window.open(url);
} }
} }
@ -293,6 +307,7 @@ class CompetitionCommon extends Component{
if (response.data) { if (response.data) {
this.props.showNotification(`报名成功,预祝您夺得桂冠!`); this.props.showNotification(`报名成功,预祝您夺得桂冠!`);
// this.props.history.replace(urls); // this.props.history.replace(urls);
this.getbannerdata()
window.open(urls) window.open(urls)
} }
} }
@ -379,8 +394,24 @@ class CompetitionCommon extends Component{
className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516">{data.competition_status === "nearly_published" ? "--" : data && data.visits_count}</div> className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516">{data.competition_status === "nearly_published" ? "--" : data && data.visits_count}</div>
</Col> </Col>
<Col className="gutter-row rankbeicenter" span={6}> <Col className="gutter-row rankbeicenter" span={6}>
<div className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516"
onClick={data.competition_status === "nearly_published" ? "" : () => this.gotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}>{data.competition_status === "nearly_published" ? "--" : data && data.member_count}</div> {data.competition_status === "ended" ?
<div className={data.mode === 2 ?data.member_of_course==true?"gutter-box CompetitionsIndexbottomvalue Competitioncolor516 cursorpointer":"gutter-box CompetitionsIndexbottomvalue Competitioncolor516":"gutter-box CompetitionsIndexbottomvalue Competitioncolor516 cursorpointer"}
// 已结束onClick={data.competition_status === "nearly_published" ? "" : () => this.gotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}
onClick={ data.mode === 2 ?data.member_of_course==true?() => this.newgotocourse(`/courses/${data.course_id}`):"":() => this.newgotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}
>{data && data.member_count}</div>
:data.competition_status === "nearly_published" ?
<div className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516"
// onClick={data.competition_status === "nearly_published" ? "" : () => this.gotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}
>{"--"}</div> :
data.competition_status === "progressing" ?
data.mode === 2 ?
<div className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516 cursorpointer" onClick={() => this.gotocourse()}>{data && data.member_count}</div> : signupdata && signupdata.personal === true ?
<div className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516 cursorpointer" onClick={() => this.gotocourse("personal")}>{data && data.member_count}</div> : <div
className="gutter-box CompetitionsIndexbottomvalue Competitioncolor516 cursorpointer"
onClick={() => this.gotocourse(`/competitions/${this.props.match.params.identifier}/enroll`)}>{data && data.member_count}</div>
:""}
</Col> </Col>
</Row> </Row>
</Col> </Col>

@ -18,7 +18,18 @@ class CompetitionContentspdfdownload extends Component{
componentDidMount(){ componentDidMount(){
window.document.title = '竞赛'; window.document.title = '竞赛';
let url=`/competitions/${this.props.match.params.identifier}/prize.json`; let url=`/competitions/${this.props.match.params.identifier}/prize.json`;
axios.get(url).then((response) => { let query=this.props.location&&this.props.location.search;
const types = query.split('user_id=')
let userid;
if(types[1]===undefined){
userid=this.props.user&&this.props.user.user_id;
}else{
userid=types[1];
}
axios.get(url,{params:{
user_id:userid,
}
}).then((response) => {
if(response.status===200){ if(response.status===200){
let datas=response.data.teams; let datas=response.data.teams;
@ -33,7 +44,6 @@ class CompetitionContentspdfdownload extends Component{
} }
}) })
} }
this.setState({ this.setState({
data:response.data, data:response.data,
teams:datas, teams:datas,

@ -39,7 +39,18 @@ class CompetitionContentspdfpeopledata extends Component {
GetawardinformationAPI = () => { GetawardinformationAPI = () => {
let url = `/competitions/${this.props.match.params.identifier}/prize.json`; let url = `/competitions/${this.props.match.params.identifier}/prize.json`;
axios.get(url).then((result) => { let query=this.props.location&&this.props.location.search;
const types = query.split('user_id=')
let userid;
if(types[1]===undefined){
userid=this.props.user&&this.props.user.user_id;
}else{
userid=types[1];
}
axios.get(url,{params:{
user_id:userid,
}
}).then((result) => {
if (result.data) { if (result.data) {
this.setState({ this.setState({
formationdata: result.data.formationdata, formationdata: result.data.formationdata,

@ -11,7 +11,7 @@ import NoneData from '../coursesPublic/NoneData'
const Search=Input.Search; const Search=Input.Search;
const pageCount = 20 const pageCount = 20
// "poll", #normal 普通作业题库; group 分组作业题库; poll问卷题库 exercise试卷题库; gtask 毕设选题题库gtopic 毕设任务 // "poll", #normal 普通作业题库; group 分组作业题库; poll问卷题库 exercise试卷题库; gtask 毕设选题题库gtopic 毕设任务
const engNameMap = { const engNameMap = {
poll: '问卷', poll: '问卷',
normal: '普通作业', normal: '普通作业',
@ -37,7 +37,7 @@ class UseBank extends Component{
componentDidMount() { componentDidMount() {
console.log("UseBank"); console.log("UseBank");
console.log(this.props); console.log(this.props);
} }
onCheckBoxChange = (checkBoxValues) => { onCheckBoxChange = (checkBoxValues) => {
this.setState({ this.setState({
@ -51,10 +51,10 @@ class UseBank extends Component{
} }
fetchAll = (arg_page) => { fetchAll = (arg_page) => {
console.log('fetchAll') console.log('fetchAll')
const courseId = this.props.match.params.coursesId const courseId = this.props.match.params.coursesId
const page = arg_page || this.state.page; const page = arg_page || this.state.page;
const { nav_my, search } = this.state const { nav_my, search } = this.state
/** /**
normal 普通作业题库 group 分组作业题库 poll问卷题库 exercise试卷题库; gtask 毕设选题题库gtopic 毕设任务 normal 普通作业题库 group 分组作业题库 poll问卷题库 exercise试卷题库; gtask 毕设选题题库gtopic 毕设任务
filter string public公共题库 2 myself我的题库 1 filter string public公共题库 2 myself我的题库 1
*/ */
@ -142,11 +142,11 @@ class UseBank extends Component{
this.setState({ this.setState({
hometypepvisible:true hometypepvisible:true
}) })
const courseId = this.props.match.params.coursesId const courseId = this.props.match.params.coursesId
let url = `/question_banks/save_banks.json` let url = `/question_banks/save_banks.json`
this.setState({ loading: true }) this.setState({ loading: true })
axios.post(url axios.post(url
,{ , {
"object_type": object_type, "object_type": object_type,
"bank_id": checkBoxValues, "bank_id": checkBoxValues,
"course_id": courseId "course_id": courseId
@ -167,7 +167,7 @@ class UseBank extends Component{
hometypepvisible:false, hometypepvisible:false,
checkBoxValues:[] checkBoxValues:[]
}) })
this.props.showNotification(response.data.message) this.props.showNotification(response.data.message)
} }
}) })
.catch( (error) =>{ .catch( (error) =>{
@ -267,14 +267,14 @@ class UseBank extends Component{
></Search> ></Search>
</div> </div>
{ {
object_list && object_list.length == 0 && page == 1 ? "" : nav_my==='myself'? object_list && object_list.length == 0 && page == 1 ? "" : nav_my === 'myself' ?
<p className="color-grey-6 mb25 edu-txt-center">选用对象你在课堂{engNameMap[object_type]}列表中已<span className="color-orange-tip">加入题库</span>{engNameMap[object_type]}</p> <p className="color-grey-6 mb25 edu-txt-center">选用对象你在课堂{engNameMap[object_type]}列表中已<span className="color-orange-tip">加入题库</span>{engNameMap[object_type]}</p>
: :
<p className="color-grey-6 mb25 edu-txt-center">选用对象题库中已设置成公共属性的所有{engNameMap[object_type]}</p> <p className="color-grey-6 mb25 edu-txt-center">选用对象题库中已设置成公共属性的所有{engNameMap[object_type]}</p>
} }
{ {
nav_my !='myself' && is_teacher == false ? nav_my != 'myself' && is_teacher == false ?
<div style={{"height":"230px"}} className="d_middle edu-txt-center"> <div style={{"height":"230px"}} className="d_middle edu-txt-center">
<div> <div>
<p className="font-16 mb20 color-grey-3">通过职业认证的教师才能访问公共题库</p> <p className="font-16 mb20 color-grey-3">通过职业认证的教师才能访问公共题库</p>
@ -296,7 +296,7 @@ class UseBank extends Component{
> >
<Checkbox.Group style={{ width: '100%' }} onChange={this.onCheckBoxChange} value={checkBoxValues}> <Checkbox.Group style={{ width: '100%' }} onChange={this.onCheckBoxChange} value={checkBoxValues}>
{ object_list && object_list.map( item => { { object_list && object_list.map( item => {
/** /**
course_list_name: "C++程序设计" course_list_name: "C++程序设计"
id: 3889 id: 3889
name: "作业3第四章 控制结构 " name: "作业3第四章 控制结构 "
@ -313,7 +313,7 @@ class UseBank extends Component{
>{item.course_list_name}</span> >{item.course_list_name}</span>
{ {
nav_my==='public' && nav_my === 'public' &&
<span className="fl with16 color-grey-6 task-hide pl10">{item.username}</span> <span className="fl with16 color-grey-6 task-hide pl10">{item.username}</span>
} }
{nav_my === "myself" ? {nav_my === "myself" ?
@ -345,15 +345,15 @@ class UseBank extends Component{
<span className="fl with45"><label className="task-hide fl" style={{"maxWidth":"208px;"}}>毕业设计2018开题报告题报</label></span> <span className="fl with45"><label className="task-hide fl" style={{"maxWidth":"208px;"}}>毕业设计2018开题报告题报</label></span>
<span className={nav_my===1?"fl with50 color-grey-6 task-hide pl5":"fl with30 color-grey-6 task-hide pl5"}>数据库原理数据库原理</span> <span className={nav_my===1?"fl with50 color-grey-6 task-hide pl5":"fl with30 color-grey-6 task-hide pl5"}>数据库原理数据库原理</span>
{ {
nav_my===2 && nav_my===2 &&
<span className="fl with16 color-grey-6 task-hide pl10">胡莎莎胡莎莎</span> <span className="fl with16 color-grey-6 task-hide pl10">胡莎莎胡莎莎</span>
} }
</p> */} </p> */}
</InfiniteScroll> </InfiniteScroll>
</div> </div>
} }
<p style={{height:"20px",lineHeight:"20px;", marginTop: '4px'}}> <p style={{height: "20px", lineHeight: "20px;", marginTop: '4px'}}>
{ {
isChecked !="" ? <span className="color-red">{isChecked}</span>:"" isChecked !="" ? <span className="color-red">{isChecked}</span>:""
} }
@ -376,4 +376,4 @@ class UseBank extends Component{
) )
} }
} }
export default UseBank; export default UseBank;

Loading…
Cancel
Save