feature/merge the Dolphin develop scala code back

This commit is contained in:
hongwei 2020-09-11 10:50:54 +02:00
parent 9a47b9bea9
commit 50a4685375
2 changed files with 46 additions and 5 deletions

View File

@ -46,7 +46,7 @@ import net.liftweb.util.Mailer.{BCC, From, Subject, To}
import net.liftweb.util._
import scala.collection.immutable.List
import scala.xml.{NodeSeq, Text}
import scala.xml.{Elem, NodeSeq, Text}
import com.openbankproject.commons.ExecutionContext.Implicits.global
import code.webuiprops.MappedWebUiPropsProvider.getWebUiPropsValue
import org.apache.commons.lang3.StringUtils
@ -54,6 +54,7 @@ import org.apache.logging.log4j.core.util.UuidUtil
import sh.ory.hydra.{ApiClient, Configuration}
import sh.ory.hydra.api.{AdminApi, PublicApi}
import sh.ory.hydra.model.AcceptLoginRequest
import net.liftweb.http.S.fmapFunc
/**
* An O-R mapped "User" class that includes first name, last name, password
@ -95,6 +96,16 @@ class AuthUser extends MegaProtoUser[AuthUser] with MdcLoggable {
override def displayName = fieldOwner.firstNameDisplayName
override val fieldId = Some(Text("txtFirstName"))
override def validations = isEmpty(Helper.i18n("Please.enter.your.first.name")) _ :: super.validations
override def _toForm: Box[Elem] =
fmapFunc({s: List[String] => this.setFromAny(s)}){name =>
Full(appendFieldId(<input type={formInputType}
maxlength={maxLen.toString}
aria-labelledby={displayName}
aria-describedby={uniqueFieldId.getOrElse("")}
name={name}
value={get match {case null => "" case s => s.toString}}/>))
}
}
override lazy val lastName = new MyLastName
@ -110,6 +121,17 @@ class AuthUser extends MegaProtoUser[AuthUser] with MdcLoggable {
override def displayName = fieldOwner.lastNameDisplayName
override val fieldId = Some(Text("txtLastName"))
override def validations = isEmpty(Helper.i18n("Please.enter.your.last.name")) _ :: super.validations
override def _toForm: Box[Elem] =
fmapFunc({s: List[String] => this.setFromAny(s)}){name =>
Full(appendFieldId(<input type={formInputType}
maxlength={maxLen.toString}
aria-labelledby={displayName}
aria-describedby={uniqueFieldId.getOrElse("")}
name={name}
value={get match {case null => "" case s => s.toString}}/>))
}
}
/**
@ -131,6 +153,16 @@ class AuthUser extends MegaProtoUser[AuthUser] with MdcLoggable {
super.validations
override val fieldId = Some(Text("txtUsername"))
override def _toForm: Box[Elem] =
fmapFunc({s: List[String] => this.setFromAny(s)}){name =>
Full(appendFieldId(<input type={formInputType}
maxlength={maxLen.toString}
aria-labelledby={displayName}
aria-describedby={uniqueFieldId.getOrElse("")}
name={name}
value={get match {case null => "" case s => s.toString}}/>))
}
/**
* Make sure that the field is unique in the CBS
*/
@ -166,12 +198,12 @@ class AuthUser extends MegaProtoUser[AuthUser] with MdcLoggable {
S.fmapFunc({s: List[String] => this.setFromAny(s)}){funcName =>
Full(
<span>
{appendFieldId(<input id="textPassword" type={formInputType} name={funcName} value={preFilledPassword}/>)}
{appendFieldId(<input id="textPassword" aria-labelledby="Password" aria-describedby={uniqueFieldId.getOrElse("")} type={formInputType} name={funcName} value={preFilledPassword}/> ) }
<div id="signup-error" class="alert alert-danger hide">
<span data-lift={s"Msg?id=${uniqueFieldId.getOrElse("")}&errorClass=error"}/>
</div>
<div id ="repeat-password">{signupPasswordRepeatText}</div>
<input id="textPasswordRepeat" type={formInputType} name={funcName} value={preFilledPassword}/>
<input id="textPasswordRepeat" aria-labelledby="Password Repeat" aria-describedby={uniqueFieldId.getOrElse("")} type={formInputType} name={funcName} value={preFilledPassword}/>
<div id="signup-error" class="alert alert-danger hide">
<span data-lift={s"Msg?id=${uniqueFieldId.getOrElse("")}_repeat&errorClass=error"}/>
</div>
@ -334,6 +366,15 @@ class AuthUser extends MegaProtoUser[AuthUser] with MdcLoggable {
case e if (!isEmailValid(e)) => List(FieldError(this, Text(S.?("invalid.email.address"))))
case _ => Nil
}
override def _toForm: Box[Elem] =
fmapFunc({s: List[String] => this.setFromAny(s)}){name =>
Full(appendFieldId(<input type={formInputType}
maxlength={maxLen.toString}
aria-labelledby={displayName}
aria-describedby={uniqueFieldId.getOrElse("")}
name={name}
value={get match {case null => "" case s => s.toString}}/>))
}
}
}
@ -545,7 +586,7 @@ import net.liftweb.util.Helpers._
scala.xml.Unparsed(s"""$agreeTermsHtml""")
}
}
def agreePrivacyPolicy = {
val url = getWebUiPropsValue("webui_agree_privacy_policy_url", "")
val text = getWebUiPropsValue("webui_agree_privacy_policy_html_text", s"""<div id="signup-agree-privacy-policy"><label>By submitting this information you consent to processing your data by TESOBE GmbH according to our <a href="$url" title="Privacy Policy">Privacy Policy</a>. TESOBE shall use this information to send you emails and provide customer support.</label></div>""")

View File

@ -173,7 +173,7 @@ object OAuthAuthorisation {
val allInputFields = (AuthUser.login \\ "input")
val submitFields = allInputFields.filter(e => e.\@("type").equalsIgnoreCase("submit"))
val extractToken = submitFields.map(e => e.\@("name"))
val submitElem = s"""<input class="submit" type="submit" value="${APIUtil.loginButtonText}" tabindex="4" name="submitButton"/>""".replace("submitButton", extractToken.headOption.getOrElse(""))
val submitElem = s"""<input class="submit" type="submit" value="${APIUtil.loginButtonText}" tabindex="0" name="submitButton"/>""".replace("submitButton", extractToken.headOption.getOrElse(""))
scala.xml.XML.loadString(submitElem)
}