<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/webflow
      http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

  <secured attributes="ROLE_ANONYMOUS"/>

  <var name="account" class="org.unitedfront2.domain.Account"/>

  <subflow-state id="captcha" subflow="captcha-sub-flow">
    <transition on="finish" to="mailSendOrNot"/>
  </subflow-state>

  <decision-state id="mailSendOrNot">
    <if test="mailService.enable" then="mailAddrForm" else="reissueManual"/>
  </decision-state>

  <!-- With Mail -->
  <view-state id="mailAddrForm" view="account.PasswordReissueForm" model="account">
    <binder>
      <binding property="mailAddr"/>
    </binder>
    <transition on="submit" to="confirm"/>
  </view-state>

  <action-state id="confirm">
    <evaluate expression="accountPasswordReissueAction.confirmPasswordReissue"/>
    <transition on="success" to="finish"/>
    <!-- エラーの場合も成功したように見せる -->
    <transition on="error" to="finish"/>
  </action-state>

  <end-state id="finish" view="account.PasswordReissueConfirm"/>

  <!-- Without Mail -->
  <subflow-state id="reissueManual" subflow="mail.inquiry-flow">
    <input name="subject" value="resourceBundle.getMessage('account.PasswordReissue', null, externalContext.requestMap._locale)" required="true"/>
    <transition on="finish" to="inquiryFinish"/>
  </subflow-state>

  <end-state id="inquiryFinish" view="mail.InquirySuccess"/>

</flow>
